/** * Performs matching of point of code * * @param mixed $point Specific part of code, can be any Reflection class * @param null|mixed $context Related context, can be class or namespace * @param null|string|object $instance Invocation instance or string for static calls * @param null|array $arguments Dynamic arguments for method * * @return bool */ public function matches($point, $context = null, $instance = null, array $arguments = null) { $isMatchesPre = $this->pointcut->getClassFilter()->matches($context); if (!$isMatchesPre) { return true; } $isMatchesPoint = $this->pointcut->matches($point, $context, $instance, $arguments); if (!$isMatchesPoint) { return true; } return false; }
/** * Performs matching of point of code * * @param mixed $point Specific part of code, can be any Reflection class * * @return bool */ public function matches($point) { $preFilter = method_exists($point, 'getDeclaringClass') ? $point->getDeclaringClass() : $point->getNamespaceName(); $isMatchesPre = $this->pointcut->getClassFilter()->matches($preFilter); if (!$isMatchesPre) { return true; } $isMatchesPoint = $this->pointcut->matches($point); if (!$isMatchesPoint) { return true; } return false; }
/** * Signature method matcher constructor * * @param Pointcut $first First filter * @param Pointcut $second Second filter */ public function __construct(Pointcut $first, Pointcut $second) { $this->first = $first; $this->second = $second; $this->kind = $first->getKind() | $second->getKind(); $this->classFilter = new OrPointFilter($first->getClassFilter(), $second->getClassFilter()); }
/** * Control flow below constructor * * @param Pointcut $pointcut Instance of pointcut, that will be used for matching * @throws \InvalidArgumentException if filter doesn't support methods */ public function __construct(Pointcut $pointcut) { $this->internalClassFilter = $pointcut->getClassFilter(); $this->internalPointFilter = $pointcut; if (!($this->internalPointFilter->getKind() & PointFilter::KIND_METHOD)) { throw new \InvalidArgumentException("Only method filters are valid for control flow"); } }
/** * Checks if point filter matches the point * * @param \ReflectionMethod|\ReflectionProperty $point * @param Pointcut $pointcut Pointcut part * * @return bool */ protected function isMatchesPointcut($point, Pointcut $pointcut) { $preFilter = method_exists($point, 'getDeclaringClass') ? $point->getDeclaringClass() : $point->getNamespaceName(); return $pointcut->matches($point) && $pointcut->getClassFilter()->matches($preFilter); }
/** * Checks if point filter matches the point * * @param \ReflectionMethod|\ReflectionProperty $point * @param Pointcut $pointcut Pointcut part * @param object|string|null $instance [Optional] Instance for dynamic matching * @param array $arguments [Optional] Extra arguments for dynamic matching * * @return bool */ protected function isMatchesPointcut($point, Pointcut $pointcut, $instance = null, array $arguments = null) { $preFilter = method_exists($point, 'getDeclaringClass') ? $point->getDeclaringClass() : $point->getNamespaceName(); return $pointcut->matches($point, $instance, $arguments) && $pointcut->getClassFilter()->matches($preFilter); }
/** * Checks if point filter matches the point * * @param Pointcut $pointcut Pointcut part * @param \ReflectionMethod|\ReflectionProperty $point * @param mixed $context Related context, can be class or namespace * @param object|string|null $instance [Optional] Instance for dynamic matching * @param array $arguments [Optional] Extra arguments for dynamic matching * * @return bool */ protected function matchPart(Pointcut $pointcut, $point, $context = null, $instance = null, array $arguments = null) { return $pointcut->matches($point, $context, $instance, $arguments) && $pointcut->getClassFilter()->matches($context); }