Injects the reflection service
public injectReflectionService ( |
||
$reflectionService | The reflection service | |
Результат | void |
/** * Checks if the class filter fires on a concrete and simple class expression * * @test */ public function matchesTellsIfTheSpecifiedRegularExpressionMatchesTheGivenClassName() { $mockReflectionService = $this->getMockBuilder(ReflectionService::class)->disableOriginalConstructor()->getMock(); $classFilter = new Aop\Pointcut\PointcutClassNameFilter('Neos\\Virtual\\Foo\\Bar'); $classFilter->injectReflectionService($mockReflectionService); $this->assertTrue($classFilter->matches('Neos\\Virtual\\Foo\\Bar', '', '', 1), 'No. 1'); $classFilter = new Aop\Pointcut\PointcutClassNameFilter('.*Virtual.*'); $classFilter->injectReflectionService($mockReflectionService); $this->assertTrue($classFilter->matches('Neos\\Virtual\\Foo\\Bar', '', '', 1), 'No. 2'); $classFilter = new Aop\Pointcut\PointcutClassNameFilter('Neos\\Firtual.*'); $classFilter->injectReflectionService($mockReflectionService); $this->assertFalse($classFilter->matches('Neos\\Virtual\\Foo\\Bar', '', '', 1), 'No. 3'); }
/** * Splits the parameters of the pointcut designator "method" into a class * and a method part and adds the appropriately configured filters to the * filter composite object. * * @param string $operator The operator * @param string $signaturePattern The pattern expression defining the class and method - the "signature" * @param PointcutFilterComposite $pointcutFilterComposite An instance of the pointcut filter composite. The result (ie. the class and method filter) will be added to this composite object. * @return void * @throws InvalidPointcutExpressionException if there's an error in the pointcut expression */ protected function parseDesignatorMethod($operator, $signaturePattern, PointcutFilterComposite $pointcutFilterComposite) { if (strpos($signaturePattern, '->') === false) { throw new InvalidPointcutExpressionException('Syntax error: "->" expected in "' . $signaturePattern . '", defined in ' . $this->sourceHint, 1169027339); } $methodVisibility = $this->getVisibilityFromSignaturePattern($signaturePattern); list($classPattern, $methodPattern) = explode('->', $signaturePattern, 2); if (strpos($methodPattern, '(') === false) { throw new InvalidPointcutExpressionException('Syntax error: "(" expected in "' . $methodPattern . '", defined in ' . $this->sourceHint, 1169144299); } $matches = []; preg_match(self::PATTERN_MATCHMETHODNAMEANDARGUMENTS, $methodPattern, $matches); $methodNamePattern = $matches['MethodName']; $methodArgumentPattern = $matches['MethodArguments']; $methodArgumentConstraints = $this->getArgumentConstraintsFromMethodArgumentsPattern($methodArgumentPattern); $classNameFilter = new PointcutClassNameFilter($classPattern); $classNameFilter->injectReflectionService($this->reflectionService); $methodNameFilter = new PointcutMethodNameFilter($methodNamePattern, $methodVisibility, $methodArgumentConstraints); /** @var SystemLoggerInterface $systemLogger */ $systemLogger = $this->objectManager->get(SystemLoggerInterface::class); $methodNameFilter->injectSystemLogger($systemLogger); $methodNameFilter->injectReflectionService($this->reflectionService); if ($operator !== '&&') { $subComposite = new PointcutFilterComposite(); $subComposite->addFilter('&&', $classNameFilter); $subComposite->addFilter('&&', $methodNameFilter); $pointcutFilterComposite->addFilter($operator, $subComposite); } else { $pointcutFilterComposite->addFilter('&&', $classNameFilter); $pointcutFilterComposite->addFilter('&&', $methodNameFilter); } }