1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Jerowork\ClassDependenciesParser; |
||
6 | |||
7 | final class ClassDependencies |
||
8 | { |
||
9 | private ?Fqn $fqn = null; |
||
10 | |||
11 | /** @var array<string, ImportedFqn> */ |
||
12 | private array $importedFqn = []; |
||
13 | |||
14 | /** @var array<string, Fqn> */ |
||
15 | private array $inlineFqn = []; |
||
16 | |||
17 | 11 | public function __construct( |
|
18 | public readonly string $filePath, |
||
19 | ) { |
||
20 | 11 | } |
|
21 | |||
22 | 5 | public function setFqn(Fqn $fqn): void |
|
23 | { |
||
24 | 5 | $this->fqn = $fqn; |
|
25 | } |
||
26 | |||
27 | 9 | public function addImportedFqn(ImportedFqn $importedFqn): void |
|
28 | { |
||
29 | 9 | $this->importedFqn[(string) $importedFqn->fqn] = $importedFqn; |
|
30 | } |
||
31 | |||
32 | 6 | public function addInlineFqn(Fqn $fqn): void |
|
33 | { |
||
34 | 6 | $this->inlineFqn[(string) $fqn] = $fqn; |
|
35 | } |
||
36 | |||
37 | 3 | public function hasImportedFqn(Fqn $fqn): bool |
|
38 | { |
||
39 | 3 | foreach ($this->importedFqn as $import) { |
|
40 | 3 | if ($import->fqn->equals($fqn)) { |
|
41 | 1 | return true; |
|
42 | } |
||
43 | } |
||
44 | |||
45 | 3 | return false; |
|
46 | } |
||
47 | |||
48 | 5 | public function getImportedFqnHavingLastPart(string $lastPart): ?ImportedFqn |
|
49 | { |
||
50 | 5 | foreach ($this->importedFqn as $import) { |
|
51 | 5 | if ($import->fqn->getLastPart() === $lastPart) { |
|
52 | 5 | return $import; |
|
53 | } |
||
54 | } |
||
55 | |||
56 | 5 | return null; |
|
57 | } |
||
58 | |||
59 | 5 | public function getImportedFqnHavingAlias(string $alias): ?ImportedFqn |
|
60 | { |
||
61 | 5 | foreach ($this->importedFqn as $import) { |
|
62 | 5 | if ($import->alias === $alias) { |
|
63 | 2 | return $import; |
|
64 | } |
||
65 | } |
||
66 | |||
67 | 5 | return null; |
|
68 | } |
||
69 | |||
70 | 5 | public function getFqn(): ?Fqn |
|
71 | { |
||
72 | 5 | return $this->fqn; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return array<string, ImportedFqn> |
||
77 | */ |
||
78 | 1 | public function getImportedFqn(): array |
|
79 | { |
||
80 | 1 | return $this->importedFqn; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return array<string, Fqn> |
||
85 | */ |
||
86 | 2 | public function getInlineFqn(): array |
|
87 | { |
||
88 | 2 | return $this->inlineFqn; |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * @return list<string> |
||
0 ignored issues
–
show
|
|||
93 | */ |
||
94 | 5 | public function getDependencyList(): array |
|
95 | { |
||
96 | 5 | $dependencies = [ |
|
97 | 5 | ...array_keys(array_filter($this->importedFqn, static fn (ImportedFqn $fqcn): bool => $fqcn->isClass)), |
|
98 | 5 | ...array_keys($this->inlineFqn), |
|
99 | 5 | ]; |
|
100 | |||
101 | 5 | sort($dependencies); |
|
102 | |||
103 | 5 | return $dependencies; |
|
104 | } |
||
105 | } |
||
106 |
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