Pointcuts are defined as a predicate over the syntax-tree of the program, and define an interface that constrains which elements of the base program are exposed by the pointcut. A pointcut picks out certain join points and values at those points
Inheritance: extends Go\Aop\PointFilter
Esempio n. 1
0
 /**
  * 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());
 }
 /**
  * {@inheritdoc}
  */
 public function getAdvice()
 {
     $advice = parent::getAdvice();
     if ($this->pointcut->getKind() & PointFilter::KIND_DYNAMIC) {
         $advice = new DynamicInvocationMatcherInterceptor($this->pointcut, $advice);
     }
     return $advice;
 }
 /**
  * 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");
     }
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
 /**
  * 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;
 }
Esempio n. 6
0
 /**
  * @inheritDoc
  */
 protected function matchPart(Pointcut $pointcut, $point, $context = null, $instance = null, array $arguments = null)
 {
     $pointcutKind = $pointcut->getKind();
     // We need to recheck filter kind one more time, because of OR syntax
     switch (true) {
         case $point instanceof \ReflectionMethod && $pointcutKind & PointFilter::KIND_METHOD:
         case $point instanceof \ReflectionProperty && $pointcutKind & PointFilter::KIND_PROPERTY:
         case $point instanceof \ReflectionClass && $pointcutKind & PointFilter::KIND_CLASS:
             return parent::matchPart($pointcut, $point, $context, $instance, $arguments);
         default:
             return false;
     }
 }
Esempio n. 7
0
 /**
  * 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);
 }
Esempio n. 8
0
 /**
  * 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);
 }
Esempio n. 9
0
 /**
  * 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);
 }