| 1 | <?php |
||
| 26 | class DefaultPointcutAdvisor extends AbstractGenericAdvisor implements PointcutAdvisor |
||
| 27 | { |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Pointcut instance |
||
| 31 | * |
||
| 32 | * @var Pointcut |
||
| 33 | */ |
||
| 34 | private $pointcut; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Create a DefaultPointcutAdvisor, specifying Pointcut and Advice. |
||
| 38 | * |
||
| 39 | * @param Pointcut $pointcut The Pointcut targeting the Advice |
||
| 40 | * @param Advice $advice The Advice to run when Pointcut matches |
||
| 41 | */ |
||
| 42 | 2 | public function __construct(Pointcut $pointcut, Advice $advice) |
|
| 43 | { |
||
| 44 | 2 | $this->pointcut = $pointcut; |
|
| 45 | 2 | parent::__construct($advice); |
|
| 46 | 2 | } |
|
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | */ |
||
| 51 | 2 | public function getAdvice() : Advice |
|
| 52 | { |
||
| 53 | 2 | $advice = parent::getAdvice(); |
|
| 54 | 2 | if ($this->pointcut->getKind() & PointFilter::KIND_DYNAMIC) { |
|
| 55 | $advice = new DynamicInvocationMatcherInterceptor( |
||
| 56 | $this->pointcut, |
||
| 57 | $advice |
||
|
|
|||
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | 2 | return $advice; |
|
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Get the Pointcut that drives this advisor. |
||
| 66 | */ |
||
| 67 | 2 | public function getPointcut() : Pointcut |
|
| 71 | } |
||
| 72 |
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.