10
10
use PHPStan \Type \FileTypeMapper ;
11
11
12
12
/**
13
- * @implements \PHPStan\Rules\Rule<\PhpParser\Node>
13
+ * @implements \PHPStan\Rules\Rule<\PhpParser\Node\Stmt >
14
14
*/
15
15
class WrongVariableNameInVarTagRule implements Rule
16
16
{
@@ -24,15 +24,13 @@ public function __construct(FileTypeMapper $fileTypeMapper)
24
24
25
25
public function getNodeType (): string
26
26
{
27
- return \PhpParser \Node::class;
27
+ return \PhpParser \Node \Stmt ::class;
28
28
}
29
29
30
30
public function processNode (Node $ node , Scope $ scope ): array
31
31
{
32
32
if (
33
33
!$ node instanceof Node \Stmt \Foreach_
34
- && !$ node instanceof Node \Expr \Assign
35
- && !$ node instanceof Node \Expr \AssignRef
36
34
&& !$ node instanceof Node \Stmt \Static_
37
35
&& !$ node instanceof Node \Stmt \Echo_
38
36
&& !$ node instanceof Node \Stmt \Return_
@@ -64,9 +62,6 @@ public function processNode(Node $node, Scope $scope): array
64
62
if (count ($ varTags ) === 0 ) {
65
63
return [];
66
64
}
67
- if ($ node instanceof Node \Expr \Assign || $ node instanceof Node \Expr \AssignRef) {
68
- return $ this ->processAssign ($ scope , $ node ->var , $ varTags );
69
- }
70
65
71
66
if ($ node instanceof Node \Stmt \Foreach_) {
72
67
return $ this ->processForeach ($ node ->keyVar , $ node ->valueVar , $ varTags );
@@ -254,7 +249,7 @@ private function processStatic(array $vars, array $varTags): array
254
249
private function processExpression (Scope $ scope , Expr $ expr , array $ varTags ): array
255
250
{
256
251
if ($ expr instanceof Node \Expr \Assign || $ expr instanceof Node \Expr \AssignRef) {
257
- return [] ;
252
+ return $ this -> processAssign ( $ scope , $ expr -> var , $ varTags ) ;
258
253
}
259
254
260
255
return $ this ->processStmt ($ scope , $ varTags , null );
0 commit comments