Go\Aop\Pointcut\SignaturePointcut::matches PHP Method

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
    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);
    }

Usage Example

 /**
  * Tests that multiple pattern is using strict matching
  *
  * @link https://github.com/lisachenko/go-aop-php/issues/115
  */
 public function testIssue115()
 {
     $filterKind = PointFilter::KIND_METHOD;
     $pointcut = new SignaturePointcut($filterKind, 'public|Public', TruePointFilter::getInstance());
     $matched = $pointcut->matches(new \ReflectionMethod(self::STUB_CLASS, 'publicMethod'));
     $this->assertFalse($matched, "Pointcut should match strict");
     $matched = $pointcut->matches(new \ReflectionMethod(self::STUB_CLASS, 'staticLsbPublic'));
     $this->assertFalse($matched, "Pointcut should match strict");
 }