1 | <?php |
||
13 | class VariableVariableUsage implements Pass\AnalyzerPassInterface, Pass\ConfigurablePassInterface |
||
14 | { |
||
15 | /** |
||
16 | * @param Expr\Assign $expr |
||
17 | * @param Context $context |
||
18 | * @return bool |
||
19 | */ |
||
20 | 13 | public function pass(Expr\Assign $expr, Context $context) |
|
35 | |||
36 | 13 | private function analyzeAssign(Expr\Assign $expr, Context $context) |
|
45 | |||
46 | 1 | private function analyzeList(Expr\List_ $expr, Context $context) |
|
61 | |||
62 | 2 | private function analyzeArrayDimFetch(Expr\ArrayDimFetch $expr, Context $context) |
|
63 | { |
||
64 | 2 | $result = false; |
|
65 | |||
66 | // $array[] = … |
||
67 | 2 | if ($expr->var instanceof Expr\Variable) { |
|
68 | 2 | $result = $this->analyzeVar($expr->var, $context); |
|
69 | 2 | } else if ($expr->var instanceof Expr\PropertyFetch) { |
|
70 | // $this->array[] = … |
||
71 | 2 | $result = $this->analyzePropertyFetch($expr->var, $context); |
|
72 | 2 | } |
|
73 | |||
74 | 2 | if ($expr->dim instanceof Expr\Variable) { |
|
75 | 1 | $result = $this->analyzeVar($expr->dim, $context) || $result; |
|
76 | 1 | } |
|
77 | |||
78 | 2 | return $result; |
|
79 | } |
||
80 | |||
81 | 2 | private function analyzePropertyFetch(Expr\PropertyFetch $expr, Context $context) |
|
90 | |||
91 | 13 | private function analyzeVar(Expr\Variable $var, Context $context) |
|
101 | |||
102 | 1 | private function notice(Context $context, Expr $expr) |
|
106 | |||
107 | /** |
||
108 | * @return array |
||
109 | */ |
||
110 | 1 | public function getRegister() |
|
116 | |||
117 | /** |
||
118 | * @return TreeBuilder |
||
119 | */ |
||
120 | public function getConfiguration() |
||
129 | } |
||
130 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.