matches() public method

Performs matching of point of code
public matches ( mixed $point, null | mixed $context = null, null | string | object $instance = null, array $arguments = null ) : boolean
$point mixed Specific part of code, can be any Reflection class
$context null | mixed Related context, can be class or namespace
$instance null | string | object Invocation instance or string for static calls
$arguments array Dynamic arguments for method
return boolean
Example #1
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)
 {
     if (!$this->modifierFilter->matches($point, $context)) {
         return false;
     }
     return $point->name === $this->name || (bool) preg_match("/^(?:{$this->regexp})\$/", $point->name);
 }
 /**
  * {@inheritdoc}
  */
 public function matches($point)
 {
     if (!$this->modifierFilter->matches($point)) {
         return false;
     }
     return $point->name === $this->name || (bool) preg_match("/^(?:{$this->regexp})\$/", $point->name);
 }
 /**
  * Performs matching of point of code
  *
  * @param mixed $method Specific part of code, can be any Reflection class
  * @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($method, $instance = null, array $arguments = null)
 {
     /** @var $method ReflectionMethod|ParsedReflectionMethod */
     if (!$method instanceof ReflectionMethod && !$method instanceof ParsedReflectionMethod) {
         return false;
     }
     if (!$this->modifierFilter->matches($method)) {
         return false;
     }
     return $method->name === $this->methodName || (bool) preg_match("/^(?:{$this->regexp})\$/", $method->name);
 }
 /**
  * Method invoker
  *
  * @param Joinpoint $joinpoint the method invocation joinpoint
  *
  * @return mixed the result of the call to {@see Joinpoint->proceed()}
  */
 public final function invoke(Joinpoint $joinpoint)
 {
     if ($joinpoint instanceof Invocation) {
         $point = $joinpoint->getStaticPart();
         $instance = $joinpoint->getThis();
         $context = new \ReflectionClass($instance);
         if ($this->pointFilter->matches($point, $context, $instance, $joinpoint->getArguments())) {
             return $this->interceptor->invoke($joinpoint);
         }
     }
     return $joinpoint->proceed();
 }
 /**
  * Performs matching of point of code
  *
  * @param mixed $method Specific part of code, can be any Reflection class
  * @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($method, $instance = null, array $arguments = null)
 {
     // With single parameter (statically) always matches for __call, __callStatic
     if (!$instance) {
         return $method->name === '__call' || $method->name === '__callStatic';
     }
     if (!$this->modifierFilter->matches($method)) {
         return false;
     }
     // for __call and __callStatic method name is the first argument on invocation
     list($methodName) = $arguments;
     return $methodName === $this->methodName || (bool) preg_match("/^(?:{$this->regexp})\$/", $methodName);
 }
 /**
  * Performs matching of point of code
  *
  * @param mixed $property
  *
  * @return bool
  */
 public function matches($property)
 {
     /** @var $property ReflectionProperty|ParsedReflectionProperty */
     if (!$property instanceof ReflectionProperty && !$property instanceof ParsedReflectionProperty) {
         return false;
     }
     if (!$this->modifierFilter->matches($property)) {
         return false;
     }
     return $property->name === $this->propertyName || (bool) preg_match("/^(?:{$this->regexp})\$/", $property->name);
 }
 /**
  * Performs matching of point of code
  *
  * @param mixed $method Specific part of code, can be any Reflection class
  * @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($method, $instance = null, array $arguments = null)
 {
     // With single parameter (statically) always matches
     if (!$instance) {
         return true;
     }
     $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     foreach ($trace as $stackFrame) {
         if (!isset($stackFrame['class'])) {
             continue;
         }
         $refClass = new ReflectionClass($stackFrame['class']);
         if (!$this->internalClassFilter->matches($refClass)) {
             continue;
         }
         $refMethod = new ReflectionMethod($stackFrame['class'], $stackFrame['function']);
         if ($this->internalPointFilter->matches($refMethod)) {
             return true;
         }
     }
     return false;
 }
Example #8
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)
 {
     return $this->first->matches($point) || $this->second->matches($point);
 }
Example #9
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)
 {
     return !$this->first->matches($point);
 }
Example #10
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)
 {
     return $this->first->matches($point, $context) && $this->second->matches($point, $context);
 }
Example #11
0
 /**
  * Returns list of function advices for specific namespace
  *
  * @param ReflectionFileNamespace $namespace
  * @param Aop\PointcutAdvisor $advisor Advisor for class
  * @param string $advisorId Identifier of advisor
  * @param Aop\PointFilter $pointcut Filter for points
  *
  * @return array
  */
 private function getFunctionAdvicesFromAdvisor($namespace, $advisor, $advisorId, $pointcut)
 {
     $functions = array();
     $advices = array();
     if (!$functions) {
         $listOfGlobalFunctions = get_defined_functions();
         foreach ($listOfGlobalFunctions['internal'] as $functionName) {
             $functions[$functionName] = new NamespacedReflectionFunction($functionName, $namespace->getName());
         }
     }
     foreach ($functions as $functionName => $function) {
         if ($pointcut->matches($function)) {
             $advices[AspectContainer::FUNCTION_PREFIX][$functionName][$advisorId] = $advisor->getAdvice();
         }
     }
     return $advices;
 }