1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Remorhaz\JSON\Path\Value; |
||
6 | |||
7 | use ReturnTypeWillChange; |
||
0 ignored issues
–
show
|
|||
8 | |||
9 | use function array_keys; |
||
10 | use function count; |
||
11 | use function in_array; |
||
12 | |||
13 | final class IndexMap implements IndexMapInterface |
||
14 | { |
||
15 | |||
16 | 35 | private $outerIndexes; |
|
17 | |||
18 | 35 | public function __construct(?int ...$outerIndexes) |
|
19 | 35 | { |
|
20 | $this->outerIndexes = $outerIndexes; |
||
21 | 11 | } |
|
22 | |||
23 | 11 | #[ReturnTypeWillChange] |
|
24 | public function count() |
||
25 | { |
||
26 | 8 | return count($this->outerIndexes); |
|
27 | } |
||
28 | 8 | ||
29 | public function getInnerIndexes(): array |
||
30 | { |
||
31 | 21 | return array_keys($this->outerIndexes); |
|
32 | } |
||
33 | 21 | ||
34 | public function getOuterIndexes(): array |
||
35 | { |
||
36 | 3 | return $this->outerIndexes; |
|
37 | } |
||
38 | 3 | ||
39 | 2 | public function getOuterIndex(int $innerIndex): int |
|
40 | { |
||
41 | if (!isset($this->outerIndexes[$innerIndex])) { |
||
42 | 1 | throw new Exception\OuterIndexNotFoundException($innerIndex, $this); |
|
43 | } |
||
44 | |||
45 | 5 | return $this->outerIndexes[$innerIndex]; |
|
46 | } |
||
47 | 5 | ||
48 | public function outerIndexExists(int $outerIndex): bool |
||
49 | { |
||
50 | 4 | return in_array($outerIndex, $this->outerIndexes, true); |
|
51 | } |
||
52 | 4 | ||
53 | public function split(): IndexMapInterface |
||
54 | { |
||
55 | 4 | return new self(...$this->getInnerIndexes()); |
|
56 | } |
||
57 | 4 | ||
58 | 4 | public function join(IndexMapInterface $indexMap): IndexMapInterface |
|
59 | 3 | { |
|
60 | 3 | $outerIndexes = []; |
|
61 | 1 | foreach ($indexMap->getOuterIndexes() as $innerIndex => $outerIndex) { |
|
62 | $outerIndexes[] = $this->outerIndexExists($innerIndex) |
||
63 | ? $outerIndex |
||
64 | 4 | : null; |
|
65 | } |
||
66 | |||
67 | 3 | return new self(...$outerIndexes); |
|
68 | } |
||
69 | 3 | ||
70 | public function equals(IndexMapInterface $indexMap): bool |
||
71 | { |
||
72 | 7 | return $this->outerIndexes === $indexMap->getOuterIndexes(); |
|
73 | } |
||
74 | 7 | ||
75 | 1 | public function isCompatible(IndexMapInterface $indexMap): bool |
|
76 | { |
||
77 | if (count($indexMap) != count($this)) { |
||
78 | 6 | return false; |
|
79 | 6 | } |
|
80 | 5 | ||
81 | 4 | $anotherMap = $indexMap->getOuterIndexes(); |
|
82 | foreach ($this->outerIndexes as $innerIndex => $outerIndex) { |
||
83 | if (!isset($outerIndex, $anotherMap[$innerIndex])) { |
||
84 | 2 | continue; |
|
85 | 1 | } |
|
86 | |||
87 | if ($outerIndex !== $anotherMap[$innerIndex]) { |
||
88 | return false; |
||
89 | 5 | } |
|
90 | } |
||
91 | |||
92 | return true; |
||
93 | } |
||
94 | } |
||
95 |
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