1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace BEAR\Resource\Module; |
||
6 | |||
7 | use BEAR\Resource\Annotation\AppName; |
||
8 | use BEAR\Resource\Annotation\ImportAppConfig; |
||
9 | use BEAR\Resource\AppAdapter; |
||
10 | use BEAR\Resource\ImportApp; |
||
11 | use BEAR\Resource\SchemeCollection; |
||
12 | use Ray\Di\InjectorInterface; |
||
13 | use Ray\Di\ProviderInterface; |
||
14 | |||
15 | /** @implements ProviderInterface<SchemeCollection> */ |
||
16 | final class ImportSchemeCollectionProvider implements ProviderInterface |
||
17 | { |
||
18 | /** @param ImportApp[] $importAppConfig */ |
||
19 | public function __construct( |
||
20 | #[AppName] |
||
21 | private readonly string $appName, |
||
22 | #[ImportAppConfig] |
||
23 | private readonly array $importAppConfig, |
||
24 | private readonly InjectorInterface $injector, |
||
25 | ) { |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * {@inheritDoc} |
||
30 | */ |
||
31 | public function get(): SchemeCollection |
||
32 | { |
||
33 | $schemeCollection = (new SchemeCollectionProvider($this->appName, $this->injector))->get(); |
||
34 | foreach ($this->importAppConfig as $importApp) { |
||
35 | $adapter = new AppAdapter($this->injector, $importApp->appName); |
||
36 | $schemeCollection |
||
37 | ->scheme('page')->host($importApp->host)->toAdapter($adapter) |
||
38 | ->scheme('app')->host($importApp->host)->toAdapter($adapter); |
||
39 | } |
||
40 | |||
41 | return $schemeCollection; |
||
0 ignored issues
–
show
|
|||
42 | } |
||
43 | } |
||
44 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: