Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | 11 | public function __invoke(Traversable $ASTs): array |
|
19 | { |
||
20 | // note: dependency injection is not really feasible for these two, as they need to co-exist in parallel |
||
21 | 11 | $traverser = new NodeTraverser(); |
|
22 | |||
23 | 11 | $traverser->addVisitor(new NameResolver()); |
|
24 | 11 | $traverser->addVisitor($collector = new UsedSymbolCollector()); |
|
25 | |||
26 | 11 | $astSymbols = []; |
|
27 | |||
28 | 11 | foreach ($ASTs as $astRoot) { |
|
29 | 9 | $traverser->traverse($astRoot); |
|
30 | |||
31 | 9 | $astSymbols[] = $collector->getCollectedSymbols(); |
|
32 | } |
||
33 | |||
34 | 11 | $usedSymbols = array_unique(array_merge([], ...$astSymbols)); |
|
35 | |||
36 | 11 | natcasesort($usedSymbols); |
|
37 | |||
38 | 11 | return array_values($usedSymbols); |
|
39 | } |
||
41 |