1 | <?php |
||
8 | class NodeSearch |
||
9 | { |
||
10 | /** |
||
11 | * @var \PhpParser\Node[] |
||
12 | */ |
||
13 | private $tree; |
||
14 | |||
15 | /** |
||
16 | * @var Node[] |
||
17 | */ |
||
18 | private $allNodes; |
||
19 | |||
20 | /** |
||
21 | * @var Node[] |
||
22 | */ |
||
23 | private $parentChain; |
||
24 | |||
25 | /** |
||
26 | * NodeSearch constructor. |
||
27 | * @param Node[] $nodes |
||
28 | */ |
||
29 | 20 | public function __construct(array $nodes) |
|
33 | |||
34 | /** |
||
35 | * @param \string[] ...$classNames |
||
36 | * @return \Traversable |
||
37 | */ |
||
38 | 18 | public function eachType(string ...$classNames): \Traversable |
|
58 | |||
59 | 5 | public function findParent(string $class, Node $fromNode) |
|
74 | |||
75 | /** |
||
76 | * @param Node $newClass |
||
77 | */ |
||
78 | 2 | public function appendToRoot(Node $newClass) |
|
82 | |||
83 | /** |
||
84 | * @return \PhpParser\Node[] |
||
85 | */ |
||
86 | 14 | public function getTree() |
|
90 | |||
91 | 20 | private function update() |
|
105 | |||
106 | /** |
||
107 | * @param Node[] $nodes |
||
108 | * @return \Traversable |
||
109 | */ |
||
110 | 20 | private function recurse(array $nodes, Node $parent = null): \Traversable |
|
132 | |||
133 | /** |
||
134 | * @param $sourceNode |
||
135 | * @param $newNode |
||
136 | */ |
||
137 | 5 | public function replaceNode(Node $sourceNode, Node $newNode) |
|
158 | |||
159 | /** |
||
160 | * @param Node $parent |
||
161 | * @param Node $sourceNode |
||
162 | * @param Node $newNode |
||
163 | * @return bool |
||
164 | */ |
||
165 | 5 | private function checkReplaceSubNodes(Node $parent, Node $sourceNode, Node $newNode): bool |
|
194 | |||
195 | /** |
||
196 | * @param string $hash |
||
197 | * @return \PhpParser\Node[] |
||
198 | */ |
||
199 | 5 | private function determineReplaceParents(string $hash): array |
|
209 | } |
||
210 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: