| 1 | <?php |
||
| 10 | class StupidUnaryOperators implements AnalyzerPassInterface |
||
| 11 | { |
||
| 12 | use DefaultMetadataPassTrait; |
||
| 13 | |||
| 14 | const DESCRIPTION = 'Checks for use of UnaryPlus `+$a` and suggests to use an int or float cast instead.'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param Expr $expr |
||
| 18 | * @param Context $context |
||
| 19 | * @return bool |
||
| 20 | */ |
||
| 21 | 10 | public function pass(Expr $expr, Context $context) |
|
| 22 | { |
||
| 23 | 10 | if (get_class($expr->expr) != get_class($expr)) { |
|
|
|
|||
| 24 | 10 | $context->notice( |
|
| 25 | 10 | 'stupid_unary_operators', |
|
| 26 | 10 | 'Better to use type casting then unary plus.', |
|
| 27 | $expr |
||
| 28 | 10 | ); |
|
| 29 | 10 | return true; |
|
| 30 | } |
||
| 31 | |||
| 32 | return false; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @return array |
||
| 37 | */ |
||
| 38 | 1 | public function getRegister() |
|
| 44 | } |
||
| 45 |
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.