ray-di /
Ray.Di
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Ray\Di; |
||
| 6 | |||
| 7 | use Ray\Di\Di\Set; |
||
| 8 | use Ray\Di\Exception\SetNotFound; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @implements ProviderInterface<mixed> |
||
| 12 | * @template T of object |
||
| 13 | */ |
||
| 14 | final class ProviderSetProvider implements ProviderInterface |
||
| 15 | { |
||
| 16 | public function __construct(private InjectionPointInterface $ip, private InjectorInterface $injector) |
||
| 17 | { |
||
| 18 | } |
||
| 19 | |||
| 20 | /** @phpstan-return ProviderProvider<object> */ |
||
| 21 | public function get(): ProviderProvider |
||
| 22 | { |
||
| 23 | $param = $this->ip->getParameter(); |
||
| 24 | $setAttribute = $param->getAttributes(Set::class); |
||
| 25 | if (! isset($setAttribute[0])) { |
||
| 26 | throw new SetNotFound((string) $this->ip->getParameter()); |
||
| 27 | } |
||
| 28 | |||
| 29 | $set = $setAttribute[0]->newInstance(); |
||
| 30 | |||
| 31 | return new ProviderProvider($this->injector, $set); |
||
|
0 ignored issues
–
show
|
|||
| 32 | } |
||
| 33 | } |
||
| 34 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: