1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Ray\Di\MultiBinding; |
6
|
|
|
|
7
|
|
|
use ArrayAccess; |
8
|
|
|
use Countable; |
9
|
|
|
use Generator; |
10
|
|
|
use Iterator; |
11
|
|
|
use IteratorAggregate; |
12
|
|
|
use LogicException; |
13
|
|
|
use Ray\Di\InjectorInterface; |
14
|
|
|
use ReturnTypeWillChange; |
|
|
|
|
15
|
|
|
|
16
|
|
|
use function array_key_exists; |
17
|
|
|
use function assert; |
18
|
|
|
use function count; |
19
|
|
|
use function is_object; |
20
|
|
|
|
21
|
|
|
final class Map implements IteratorAggregate, ArrayAccess, Countable |
22
|
|
|
{ |
23
|
|
|
/** @var array<string, Lazy> $lazies */ |
24
|
|
|
private $lazies; |
25
|
|
|
|
26
|
|
|
/** @var InjectorInterface */ |
27
|
|
|
private $injector; |
28
|
|
|
|
29
|
|
|
/** @param array<string, Lazy> $lazies */ |
30
|
|
|
public function __construct(array $lazies, InjectorInterface $injector) |
31
|
|
|
{ |
32
|
|
|
$this->lazies = $lazies; |
33
|
|
|
$this->injector = $injector; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** @param string $offset */ |
37
|
|
|
#[ReturnTypeWillChange] |
38
|
|
|
public function offsetExists($offset): bool |
39
|
|
|
{ |
40
|
|
|
return array_key_exists($offset, $this->lazies); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param string $offset |
45
|
|
|
* |
46
|
|
|
* @return mixed |
47
|
|
|
*/ |
48
|
|
|
#[ReturnTypeWillChange] |
49
|
|
|
public function offsetGet($offset) |
50
|
|
|
{ |
51
|
|
|
$lazy = $this->lazies[$offset]; |
52
|
|
|
|
53
|
|
|
/** @var Lazy $lazy */ |
54
|
|
|
return $lazy($this->injector); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param string $offset |
59
|
|
|
* @param mixed $value |
60
|
|
|
* |
61
|
|
|
* @return never |
|
|
|
|
62
|
|
|
*/ |
63
|
|
|
#[ReturnTypeWillChange] |
64
|
|
|
public function offsetSet($offset, $value) |
65
|
|
|
{ |
66
|
|
|
throw new LogicException(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param string $offset |
71
|
|
|
* |
72
|
|
|
* @return never |
73
|
|
|
*/ |
74
|
|
|
#[ReturnTypeWillChange] |
75
|
|
|
public function offsetUnset($offset) |
76
|
|
|
{ |
77
|
|
|
throw new LogicException(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** @return Generator<int, object> */ |
81
|
|
|
public function getIterator(): Iterator |
82
|
|
|
{ |
83
|
|
|
foreach ($this->lazies as $lazy) { |
84
|
|
|
$object = ($lazy)($this->injector); |
85
|
|
|
assert(is_object($object)); |
86
|
|
|
|
87
|
|
|
yield $object; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function count(): int |
92
|
|
|
{ |
93
|
|
|
return count($this->lazies); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
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