1 | <?php |
||
21 | final class FlashMessage extends BasePHPVisitor implements NodeVisitor |
||
22 | { |
||
23 | 2 | public function beforeTraverse(array $nodes) |
|
26 | |||
27 | 2 | public function enterNode(Node $node) |
|
28 | { |
||
29 | 2 | if (!$node instanceof Node\Expr\MethodCall) { |
|
30 | 2 | return; |
|
31 | } |
||
32 | |||
33 | 2 | if (!is_string($node->name) && !$node->name instanceof Node\Identifier) { |
|
34 | 1 | return; |
|
35 | } |
||
36 | |||
37 | 2 | $name = (string) $node->name; |
|
38 | 2 | $caller = $node->var; |
|
39 | // $caller might be "Node\Expr\New_" |
||
40 | 2 | $callerName = isset($caller->name) ? $caller->name : ''; |
|
|
|||
41 | |||
42 | /* |
||
43 | * Make sure the caller is from a variable named "this" or a function called "getFlashbag" |
||
44 | */ |
||
45 | //If $this->addFlash() or xxx->getFlashbag()->add() |
||
46 | 2 | if (('addFlash' === $name && 'this' === $callerName && $caller instanceof Node\Expr\Variable) || |
|
47 | 2 | ('add' === $name && 'getFlashBag' === $callerName && $caller instanceof Node\Expr\MethodCall) |
|
48 | ) { |
||
49 | 2 | if (null !== $label = $this->getStringArgument($node, 1)) { |
|
50 | 2 | $this->addLocation($label, $node->getAttribute('startLine'), $node); |
|
51 | } |
||
52 | } |
||
53 | 2 | } |
|
54 | |||
55 | 2 | public function leaveNode(Node $node) |
|
58 | |||
59 | 2 | public function afterTraverse(array $nodes) |
|
62 | } |
||
63 |
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.