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