ray-di /
Ray.Di
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Ray\Di; |
||
| 6 | |||
| 7 | use Ray\Aop\MethodInvocation; |
||
| 8 | use Ray\Di\Exception\MethodInvocationNotAvailable; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @implements ProviderInterface<MethodInvocation> |
||
| 12 | */ |
||
| 13 | final class MethodInvocationProvider implements ProviderInterface |
||
| 14 | { |
||
| 15 | /** @var ?MethodInvocation<object> */ |
||
| 16 | private ?MethodInvocation $invocation = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param MethodInvocation<object> $invocation |
||
| 20 | */ |
||
| 21 | public function set(MethodInvocation $invocation): void |
||
| 22 | { |
||
| 23 | $this->invocation = $invocation; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return MethodInvocation<object> |
||
| 28 | */ |
||
| 29 | public function get(): MethodInvocation |
||
| 30 | { |
||
| 31 | if ($this->invocation === null) { |
||
| 32 | throw new MethodInvocationNotAvailable(); |
||
| 33 | } |
||
| 34 | |||
| 35 | return $this->invocation; |
||
|
0 ignored issues
–
show
|
|||
| 36 | } |
||
| 37 | } |
||
| 38 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: