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