These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | /** |
||
5 | * This file is part of phpDocumentor. |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | * |
||
10 | * @author Mike van Riel <[email protected]> |
||
11 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
12 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
13 | * @link http://phpdoc.org |
||
14 | */ |
||
15 | |||
16 | namespace Pimple; |
||
17 | |||
18 | use ArrayAccess; |
||
19 | use ArrayObject; |
||
20 | use Closure; |
||
21 | use Psr\Container\NotFoundExceptionInterface; |
||
22 | use Symfony\Component\Console\Command\Command; |
||
23 | use Symfony\Component\DependencyInjection\ContainerInterface; |
||
24 | |||
25 | if (!class_exists(\Pimple\Container::class, false)) { |
||
26 | class Container implements ArrayAccess |
||
27 | { |
||
28 | /** |
||
29 | * @var ContainerInterface |
||
30 | */ |
||
31 | protected $container; |
||
32 | |||
33 | 1 | public function __construct(ContainerInterface $container) |
|
34 | { |
||
35 | 1 | $this->container = $container; |
|
36 | 1 | } |
|
37 | |||
38 | /** |
||
39 | * @param mixed $offset |
||
40 | * @see ArrayAccess::offsetExists() |
||
41 | */ |
||
42 | public function offsetExists($offset): bool |
||
43 | { |
||
44 | return $this->container->has($offset); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param mixed $offset |
||
49 | * @return mixed |
||
50 | * @see ArrayAccess::offsetGet() |
||
51 | */ |
||
52 | 1 | public function offsetGet($offset) |
|
53 | { |
||
54 | try { |
||
55 | 1 | return $this->container->get($offset); |
|
56 | } catch (NotFoundExceptionInterface $exception) { |
||
57 | return null; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param mixed $offset |
||
63 | * @param mixed $value |
||
64 | * @see ArrayAccess::offsetSet() |
||
65 | */ |
||
66 | 1 | public function offsetSet($offset, $value): void |
|
67 | { |
||
68 | 1 | if ($value instanceof Closure) { |
|
69 | $value = $value($this); |
||
70 | } |
||
71 | 1 | $this->container->set($offset, $value); |
|
72 | 1 | } |
|
73 | |||
74 | /** |
||
75 | * @param mixed $offset |
||
76 | * @see ArrayAccess::offsetUnset() |
||
77 | */ |
||
78 | public function offsetUnset($offset): void |
||
79 | { |
||
80 | $this->container->set($offset, null); |
||
0 ignored issues
–
show
|
|||
81 | } |
||
82 | |||
83 | public function register(ServiceProviderInterface $serviceProvider): void |
||
84 | { |
||
85 | $serviceProvider->register($this); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @return mixed |
||
90 | */ |
||
91 | public function extend(string $serviceId, Closure $extendingService) |
||
92 | { |
||
93 | return $extendingService($this->container->get($serviceId)); |
||
94 | } |
||
95 | |||
96 | public function command(Command $command): void |
||
97 | { |
||
98 | if (! $this->container->has('phpdocumentor.compatibility.extra_commands')) { |
||
99 | $this->container->set('phpdocumentor.compatibility.extra_commands', new ArrayObject()); |
||
100 | } |
||
101 | /** @var \ArrayObject $commands */ |
||
102 | $commands = $this->container->get('phpdocumentor.compatibility.extra_commands'); |
||
103 | |||
104 | $commands->append($command); |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: