| 1 | <?php |
||
| 13 | class AssignRefNew implements AnalyzerPassInterface |
||
| 14 | { |
||
| 15 | use DefaultMetadataPassTrait { |
||
| 16 | DefaultMetadataPassTrait::getMetadata as defaultMetadata; |
||
| 17 | } |
||
| 18 | |||
| 19 | const DESCRIPTION = 'Protection of usage & and new.'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param Expr\AssignRef $expr |
||
| 23 | * @param Context $context |
||
| 24 | * @return bool |
||
| 25 | */ |
||
| 26 | 1 | public function pass(Expr\AssignRef $expr, Context $context) |
|
| 27 | { |
||
| 28 | 1 | if ($expr->expr instanceof Expr\New_) { |
|
| 29 | 1 | $context->notice( |
|
| 30 | 1 | 'assign_ref_new', |
|
| 31 | 1 | 'Do not use = & new, all objects in PHP are passed by reference', |
|
| 32 | $expr |
||
| 33 | 1 | ); |
|
| 34 | |||
| 35 | 1 | return true; |
|
| 36 | } |
||
| 37 | |||
| 38 | return false; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return array |
||
| 43 | */ |
||
| 44 | 1 | public function getRegister() |
|
| 50 | } |
||
| 51 |