1 | <?php |
||
13 | class AnonymousClassReplacer extends NodeVisitorAbstract |
||
14 | { |
||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $anonymousClassNodes = []; |
||
19 | |||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | public function leaveNode(Node $node) |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function afterTraverse(array $nodes) |
||
69 | |||
70 | /** |
||
71 | * Find the index of the first statement that is not a declare, use or namespace statement. |
||
72 | * |
||
73 | * @param array $statements |
||
74 | * |
||
75 | * @return int |
||
76 | * |
||
77 | * @throws \Spatie\Php7to5\Exceptions\InvalidPhpCode |
||
78 | */ |
||
79 | protected function getAnonymousClassHookIndex(array $statements) |
||
97 | |||
98 | /** |
||
99 | * @param array $nodes |
||
100 | * @param $hookIndex |
||
101 | * @param $anonymousClassStatements |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | protected function moveAnonymousClassesToHook(array $nodes, $hookIndex, $anonymousClassStatements) |
||
112 | |||
113 | /** |
||
114 | * @param array $php7statements |
||
115 | * |
||
116 | * @return \PhpParser\Node[] |
||
117 | */ |
||
118 | public function convertToPhp5Statements(array $php7statements) |
||
126 | } |
||
127 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.