| 1 | <?php |
||
| 10 | class MissingBody implements AnalyzerPassInterface |
||
| 11 | { |
||
| 12 | use DefaultMetadataPassTrait; |
||
| 13 | |||
| 14 | const DESCRIPTION = 'Checks that statements that define a block of statements are not empty.'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param Stmt $stmt |
||
| 18 | * @param Context $context |
||
| 19 | * @return bool |
||
| 20 | */ |
||
| 21 | 22 | public function pass(Stmt $stmt, Context $context) |
|
| 22 | { |
||
| 23 | 22 | if ($stmt instanceof Stmt\ClassMethod && $stmt->isAbstract()) { // abstract classes are ok |
|
| 24 | 1 | return false; |
|
| 25 | } |
||
| 26 | |||
| 27 | 22 | if ($stmt instanceof Stmt\Switch_) { |
|
| 28 | 2 | $counting = $stmt->cases; |
|
| 29 | 2 | } else { |
|
| 30 | 22 | $counting = $stmt->stmts; |
|
|
|
|||
| 31 | } |
||
| 32 | |||
| 33 | 22 | if (count($counting) === 0) { |
|
| 34 | 10 | $context->notice( |
|
| 35 | 10 | 'missing_body', |
|
| 36 | 10 | 'Missing Body', |
|
| 37 | $stmt |
||
| 38 | 10 | ); |
|
| 39 | |||
| 40 | 10 | return true; |
|
| 41 | } |
||
| 42 | |||
| 43 | 15 | return false; |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return array |
||
| 48 | */ |
||
| 49 | 1 | public function getRegister() |
|
| 66 | } |
||
| 67 |
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.