1 | <?php |
||
14 | class UnexpectedUseOfThis implements Pass\AnalyzerPassInterface |
||
15 | { |
||
16 | use DefaultMetadataPassTrait; |
||
17 | |||
18 | /** |
||
19 | * @param Node\Stmt $stmt |
||
20 | * @param Context $context |
||
21 | * @return bool |
||
22 | */ |
||
23 | 23 | public function pass(Node\Stmt $stmt, Context $context) |
|
53 | |||
54 | /** |
||
55 | * @return array |
||
56 | */ |
||
57 | 1 | public function getRegister() |
|
68 | |||
69 | /** |
||
70 | * @param Stmt\ClassMethod $methodStmt |
||
71 | * @param Context $context |
||
72 | * @return bool |
||
73 | */ |
||
74 | 23 | private function inspectClassMethodArguments(Stmt\ClassMethod $methodStmt, Context $context) |
|
91 | |||
92 | /** |
||
93 | * @param Stmt\TryCatch $tryCatchStmt |
||
94 | * @param Context $context |
||
95 | * @return bool |
||
96 | */ |
||
97 | 1 | private function inspectTryCatch(Stmt\TryCatch $tryCatchStmt, Context $context) |
|
115 | |||
116 | /** |
||
117 | * @param Stmt\Foreach_ $foreachStmt |
||
118 | * @param Context $context |
||
119 | * @return bool |
||
120 | */ |
||
121 | 1 | private function inspectForeach(Stmt\Foreach_ $foreachStmt, Context $context) |
|
122 | { |
||
123 | 1 | if ($foreachStmt->valueVar->name === 'this') { |
|
|
|||
124 | 1 | $context->notice( |
|
125 | 1 | 'unexpected_use.this', |
|
126 | 1 | 'Foreach loop can not use a value variable named "this".', |
|
127 | 1 | $foreachStmt->valueVar |
|
128 | 1 | ); |
|
129 | |||
130 | 1 | return true; |
|
131 | } |
||
132 | |||
133 | 1 | return false; |
|
134 | } |
||
135 | |||
136 | /** |
||
137 | * @param Stmt\Static_ $staticStmt |
||
138 | * @param Context $context |
||
139 | * @return bool |
||
140 | */ |
||
141 | 1 | private function inspectStaticVar(Stmt\Static_ $staticStmt, Context $context) |
|
160 | |||
161 | /** |
||
162 | * @param Stmt\Global_ $globalStmt |
||
163 | * @param Context $context |
||
164 | * @return bool |
||
165 | */ |
||
166 | 1 | private function inspectGlobalVar(Stmt\Global_ $globalStmt, Context $context) |
|
184 | |||
185 | /** |
||
186 | * @param Stmt\Unset_ $unsetStmt |
||
187 | * @param Context $context |
||
188 | * @return bool |
||
189 | */ |
||
190 | 1 | private function inspectUnset(Stmt\Unset_ $unsetStmt, Context $context) |
|
208 | } |
||
209 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.