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