Skip to content

Commit 3357f95

Browse files
mpesarisamsonasik
authored andcommitted
Test RemoveNonExistingVarAnnotationRector with static variable in method
1 parent d830051 commit 3357f95

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector\Fixture;
4+
5+
final class SkipStaticVariableInMethod
6+
{
7+
public function run(int $param): int
8+
{
9+
/**
10+
* Rector should not remove this @var annotation.
11+
*
12+
* @var array<int,int>
13+
*/
14+
static $cached_result = [];
15+
16+
if (!isset($cached_result[$param])) {
17+
$cached_result[$param] = doExpensiveCalculation($param);
18+
}
19+
20+
return $cached_result[$param];
21+
}
22+
}

0 commit comments

Comments
 (0)