1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * For the full copyright and license information, please view |
||||
5 | * the LICENSE file that was distributed with this source code. |
||||
6 | */ |
||||
7 | |||||
8 | declare(strict_types=1); |
||||
9 | |||||
10 | namespace loophp\phptree\Importer; |
||||
11 | |||||
12 | use ast\Node; |
||||
0 ignored issues
–
show
|
|||||
13 | use Exception; |
||||
14 | use loophp\phptree\Node\AttributeNode; |
||||
15 | use loophp\phptree\Node\AttributeNodeInterface; |
||||
16 | use loophp\phptree\Node\NodeInterface; |
||||
17 | |||||
18 | use function ast\get_metadata; |
||||
0 ignored issues
–
show
|
|||||
19 | |||||
20 | /** |
||||
21 | * Class NikicPhpAst. |
||||
22 | */ |
||||
23 | final class NikicPhpAst implements ImporterInterface |
||||
24 | { |
||||
25 | /** |
||||
26 | * @var array<int, \ast\Metadata> |
||||
27 | */ |
||||
28 | private $metadata = []; |
||||
29 | |||||
30 | /** |
||||
31 | * @param Node $data |
||||
32 | * |
||||
33 | * @throws Exception |
||||
34 | */ |
||||
35 | 1 | public function import($data): NodeInterface |
|||
36 | { |
||||
37 | 1 | $this->metadata = get_metadata(); |
|||
0 ignored issues
–
show
The function
get_metadata was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
38 | |||||
39 | 1 | return $this->parseNode($this->createNode(['label' => 'root']), $data); |
|||
40 | } |
||||
41 | |||||
42 | 1 | private function createNode(array $attributes): AttributeNodeInterface |
|||
43 | { |
||||
44 | 1 | return new AttributeNode($attributes); |
|||
45 | } |
||||
46 | |||||
47 | /** |
||||
48 | * @param Node ...$astNodes |
||||
49 | */ |
||||
50 | 1 | private function parseNode(AttributeNodeInterface $parent, Node ...$astNodes): NodeInterface |
|||
51 | { |
||||
52 | 1 | return array_reduce( |
|||
53 | 1 | $astNodes, |
|||
54 | function (AttributeNodeInterface $carry, Node $astNode): NodeInterface { |
||||
55 | return $carry |
||||
56 | 1 | ->add( |
|||
57 | 1 | $this->parseNode( |
|||
58 | 1 | $this->createNode([ |
|||
59 | 1 | 'label' => $this->metadata[$astNode->kind]->name, |
|||
60 | 1 | 'astNode' => $astNode, |
|||
61 | ]), |
||||
62 | 1 | ...array_values(array_filter($astNode->children, 'is_object')) |
|||
63 | ) |
||||
64 | ); |
||||
65 | 1 | }, |
|||
66 | $parent |
||||
67 | ); |
||||
68 | } |
||||
69 | } |
||||
70 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths