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