1 | <?php declare(strict_types=1); |
||
10 | class Container implements ContainerInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var \League\Container\Definition\DefinitionAggregateInterface |
||
14 | */ |
||
15 | protected $definitions; |
||
16 | |||
17 | /** |
||
18 | * @var \League\Container\ServiceProvider\ServiceProviderAggregateInterface |
||
19 | */ |
||
20 | protected $providers; |
||
21 | |||
22 | /** |
||
23 | * @var \League\Container\Inflector\InflectorAggregateInterface |
||
24 | */ |
||
25 | protected $inflectors; |
||
26 | |||
27 | /** |
||
28 | * @var \Psr\Container\ContainerInterface[] |
||
29 | */ |
||
30 | protected $delegates = []; |
||
31 | |||
32 | /** |
||
33 | * Construct. |
||
34 | * |
||
35 | * @param \League\Container\Definition\DefinitionAggregateInterface|null $definitions |
||
36 | * @param \League\Container\ServiceProvider\ServiceProviderAggregateInterface|null $providers |
||
37 | * @param \League\Container\Inflector\InflectorAggregateInterface|null $inflectors |
||
38 | */ |
||
39 | public function __construct( |
||
48 | |||
49 | /** |
||
50 | * Add an item to the container. |
||
51 | * |
||
52 | * @param string $id |
||
53 | * @param mixed $concrete |
||
54 | * @param boolean $shared |
||
55 | * |
||
56 | * @return \League\Container\Definition\DefinitionInterface |
||
57 | */ |
||
58 | public function add(string $id, $concrete = null, bool $shared = false): DefinitionInterface |
||
64 | |||
65 | /** |
||
66 | 57 | * Get a definition to extend. |
|
67 | 56 | * |
|
68 | 39 | * @param string $id [description] |
|
69 | * |
||
70 | 57 | * @return \League\Container\Definition\DefinitionInterface |
|
71 | 57 | */ |
|
72 | 38 | public function extend(string $id): DefinitionInterface |
|
86 | 21 | ||
87 | 21 | /** |
|
88 | 12 | * Add a service provider. |
|
89 | * |
||
90 | 12 | * @param \League\Container\ServiceProvider\ServiceProviderInterface|string $provider |
|
91 | * |
||
92 | * @return self |
||
93 | 9 | */ |
|
94 | public function addServiceProvider($provider): self |
||
100 | |||
101 | /** |
||
102 | 21 | * {@inheritdoc} |
|
103 | */ |
||
104 | 21 | public function get($id, array $args = [], bool $new = false) |
|
125 | |||
126 | 51 | /** |
|
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function has($id): bool |
||
147 | 12 | ||
148 | 33 | /** |
|
149 | * Allows for manipulation of specific types on resolution. |
||
150 | * |
||
151 | 39 | * @param string $type |
|
152 | * @param callable|null $callback |
||
153 | * |
||
154 | * @return \League\Container\Inflector\InflectorInterface |
||
155 | 6 | */ |
|
156 | 6 | public function inflector(string $type, callable $callback = null): InflectorInterface |
|
160 | |||
161 | 33 | /** |
|
162 | * Delegate a backup container to be checked for services if it |
||
163 | 33 | * cannot be resolved via this container. |
|
164 | * |
||
165 | * @param \Psr\Container\ContainerInterface $container |
||
166 | * |
||
167 | * @return self |
||
168 | */ |
||
169 | 12 | public function delegate(ContainerInterface $container): self |
|
179 | } |
||
180 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.