<?php
namespace Rector\Tests\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector\Fixture;
final class DemoFile
{
public function run(int $param): int
{
/**
* Rector should not remove this @var annotation.
*
* @var array<int,int>
*/
static $cached_result = [];
if (!isset($cached_result[$param])) {
$cached_result[$param] = doExpensiveCalculation($param);
}
return $cached_result[$param];
}
}
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/b3ad4952-df3b-44c7-8823-e1b0fe090d27
Responsible rules
RemoveNonExistingVarAnnotationRectorExpected Behavior
The
@varannotation ofstatic $variablein method should not be removed.