1 | <?php |
||||||
2 | |||||||
3 | /* |
||||||
4 | * This file is part of the Micro framework package. |
||||||
5 | * |
||||||
6 | * (c) Stanislau Komar <[email protected]> |
||||||
7 | * |
||||||
8 | * For the full copyright and license information, please view the LICENSE |
||||||
9 | * file that was distributed with this source code. |
||||||
10 | */ |
||||||
11 | |||||||
12 | namespace Micro\Framework\Kernel\Boot; |
||||||
13 | |||||||
14 | use Micro\Component\DependencyInjection\Autowire\AutowireHelperFactory; |
||||||
15 | use Micro\Component\DependencyInjection\Autowire\AutowireHelperInterface; |
||||||
16 | use Micro\Component\DependencyInjection\Autowire\ContainerAutowire; |
||||||
17 | use Micro\Component\DependencyInjection\Container; |
||||||
18 | use Micro\Framework\Kernel\Plugin\DependencyProviderInterface; |
||||||
19 | use Micro\Framework\Kernel\Plugin\PluginBootLoaderInterface; |
||||||
20 | use Psr\Container\ContainerInterface; |
||||||
21 | |||||||
22 | class DependencyProviderBootLoader implements PluginBootLoaderInterface |
||||||
23 | { |
||||||
24 | /** |
||||||
25 | * @var Container |
||||||
26 | */ |
||||||
27 | private readonly ContainerInterface $container; |
||||||
28 | |||||||
29 | /** |
||||||
30 | * @param Container $container |
||||||
31 | */ |
||||||
32 | 1 | public function __construct(ContainerInterface $container) |
|||||
33 | { |
||||||
34 | 1 | if (!($container instanceof ContainerAutowire)) { |
|||||
35 | 1 | $container = new ContainerAutowire($container); |
|||||
36 | } |
||||||
37 | |||||||
38 | 1 | $this->container = $container; |
|||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
39 | |||||||
40 | 1 | $this->container->register(AutowireHelperInterface::class, |
|||||
0 ignored issues
–
show
The method
register() does not exist on Psr\Container\ContainerInterface . It seems like you code against a sub-type of Psr\Container\ContainerInterface such as Micro\Component\DependencyInjection\Container .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
41 | 1 | fn () => (new AutowireHelperFactory($this->container)) |
|||||
42 | 1 | ->create() |
|||||
43 | 1 | ); |
|||||
44 | } |
||||||
45 | |||||||
46 | /** |
||||||
47 | * @TODO: uncomment at 2.0 version |
||||||
48 | * {@inheritDoc} |
||||||
49 | */ |
||||||
50 | 1 | public function boot(object $applicationPlugin): void |
|||||
51 | { |
||||||
52 | 1 | if (!($applicationPlugin instanceof DependencyProviderInterface)) { |
|||||
53 | 1 | return; |
|||||
54 | } |
||||||
55 | |||||||
56 | 1 | $applicationPlugin->provideDependencies($this->container); |
|||||
57 | } |
||||||
58 | } |
||||||
59 |