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 */ |
||
16 | private $invocation; |
||
17 | |||
18 | public function set(MethodInvocation $invocation): void |
||
19 | { |
||
20 | $this->invocation = $invocation; |
||
21 | } |
||
22 | |||
23 | public function get(): MethodInvocation |
||
24 | { |
||
25 | if ($this->invocation === null) { |
||
26 | throw new MethodInvocationNotAvailable(); |
||
27 | } |
||
28 | |||
29 | return $this->invocation; |
||
0 ignored issues
–
show
|
|||
30 | } |
||
31 | } |
||
32 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: