|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Xervice\Core\Business\Model\Dependency; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use Xervice\Core\Business\Model\Config\ConfigInterface; |
|
8
|
|
|
use Xervice\Core\Business\Model\Dependency\Provider\DependencyProviderInterface; |
|
9
|
|
|
use Xervice\Core\Business\Model\Locator\Locator; |
|
10
|
|
|
use Xervice\Core\Business\Model\Locator\Proxy\AbstractLocatorProxy; |
|
11
|
|
|
use Xervice\Core\Business\Model\Locator\Proxy\LocatorProxyInterface; |
|
12
|
|
|
|
|
13
|
|
|
class AbstractDependencyContainer implements DependencyContainerInterface |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var array |
|
17
|
|
|
*/ |
|
18
|
|
|
private $dependencies; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var array |
|
22
|
|
|
*/ |
|
23
|
|
|
private $values; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var \Xervice\Core\Business\Model\Config\ConfigInterface |
|
27
|
|
|
*/ |
|
28
|
|
|
private $config; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var \Xervice\Core\Business\Model\Locator\Locator |
|
32
|
|
|
*/ |
|
33
|
|
|
private $locator; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* AbstractDependencyContainer constructor. |
|
37
|
|
|
* |
|
38
|
|
|
* @param \Xervice\Core\Business\Model\Config\ConfigInterface $config |
|
39
|
|
|
* @param \Xervice\Core\Business\Model\Locator\Locator $locator |
|
40
|
|
|
*/ |
|
41
|
4 |
|
public function __construct( |
|
42
|
|
|
ConfigInterface $config, |
|
43
|
|
|
Locator $locator |
|
44
|
|
|
) { |
|
45
|
4 |
|
$this->config = $config; |
|
46
|
4 |
|
$this->locator = $locator; |
|
47
|
4 |
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param string $name |
|
51
|
|
|
* @param callable $callable |
|
52
|
|
|
* |
|
53
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
54
|
|
|
*/ |
|
55
|
1 |
|
public function set(string $name, callable $callable): DependencyContainerInterface |
|
56
|
|
|
{ |
|
57
|
1 |
|
$this->offsetSet($name, $callable); |
|
58
|
|
|
|
|
59
|
1 |
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param string $name |
|
64
|
|
|
* |
|
65
|
|
|
* @return mixed |
|
66
|
|
|
*/ |
|
67
|
1 |
|
public function get(string $name) |
|
68
|
|
|
{ |
|
69
|
1 |
|
return $this->offsetGet($name); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param mixed $offset |
|
74
|
|
|
* |
|
75
|
|
|
* @return bool |
|
76
|
|
|
*/ |
|
77
|
|
|
public function offsetExists($offset): bool |
|
78
|
|
|
{ |
|
79
|
|
|
return isset($this->dependencies[$offset]); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param mixed $offset |
|
84
|
|
|
* |
|
85
|
|
|
* @return mixed |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function offsetGet($offset) |
|
88
|
|
|
{ |
|
89
|
1 |
|
if (!isset($this->values[$offset])) { |
|
90
|
1 |
|
$this->values[$offset] = $this->dependencies[$offset]($this); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
1 |
|
return $this->values[$offset]; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param mixed $offset |
|
98
|
|
|
* @param mixed $value |
|
99
|
|
|
*/ |
|
100
|
1 |
|
public function offsetSet($offset, $value) |
|
101
|
|
|
{ |
|
102
|
1 |
|
$this->dependencies[$offset] = $value; |
|
103
|
1 |
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @param mixed $offset |
|
107
|
|
|
*/ |
|
108
|
1 |
|
public function offsetUnset($offset) |
|
109
|
|
|
{ |
|
110
|
1 |
|
unset($this->dependencies[$offset], $this->values[$offset]); |
|
111
|
1 |
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\Provider\DependencyProviderInterface $dependencyProvider |
|
115
|
|
|
* |
|
116
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
117
|
|
|
*/ |
|
118
|
3 |
|
public function register(DependencyProviderInterface $dependencyProvider): DependencyContainerInterface |
|
119
|
|
|
{ |
|
120
|
3 |
|
$this->values = []; |
|
121
|
3 |
|
return $dependencyProvider->handleDependencies($this); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @param string $name |
|
126
|
|
|
* @param callable $callable |
|
127
|
|
|
*/ |
|
128
|
1 |
|
public function extend(string $name, callable $callable): void |
|
129
|
|
|
{ |
|
130
|
1 |
|
$value = $this->offsetGet($name); |
|
131
|
1 |
|
$this->offsetUnset($name); |
|
132
|
|
|
$this->offsetSet($name, function () use ($callable, $value) { |
|
133
|
1 |
|
return $callable($value); |
|
134
|
1 |
|
}); |
|
135
|
1 |
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return \Generated\Ide\LocatorAutoComplete|\Xervice\Core\Business\Model\Locator\Locator |
|
|
|
|
|
|
139
|
|
|
*/ |
|
140
|
1 |
|
public function getLocator(): Locator |
|
141
|
|
|
{ |
|
142
|
1 |
|
return $this->locator; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @return \Xervice\Core\Business\Model\Config\ConfigInterface |
|
147
|
|
|
*/ |
|
148
|
1 |
|
public function getConfig(): ConfigInterface |
|
149
|
|
|
{ |
|
150
|
1 |
|
return $this->config; |
|
151
|
|
|
} |
|
152
|
|
|
} |
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