1 | <?php |
||
14 | final class AssistedInterceptor implements MethodInterceptor |
||
15 | { |
||
16 | /** |
||
17 | * @var InjectorInterface |
||
18 | */ |
||
19 | private $injector; |
||
20 | |||
21 | 2 | public function __construct(InjectorInterface $injector) |
|
25 | |||
26 | /** |
||
27 | * Intercepts any method and injects instances of the missing arguments |
||
28 | * when they are type hinted |
||
29 | */ |
||
30 | 2 | public function invoke(MethodInvocation $invocation) |
|
43 | |||
44 | 2 | private function getName(ReflectionMethod $method, \ReflectionParameter $parameter) |
|
58 | |||
59 | /** |
||
60 | * @param \ReflectionMethod $method |
||
61 | * @param Assisted $assisted |
||
62 | * @param \ReflectionParameter[] $parameters |
||
63 | * @param array $arguments |
||
64 | * @param int $cntArgs |
||
65 | * |
||
66 | * @return array |
||
67 | */ |
||
68 | 2 | public function injectAssistedParameters(\ReflectionMethod $method, Assisted $assisted, array $parameters, array $arguments, $cntArgs) |
|
82 | } |
||
83 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.