/** * Checks if the specified class matches with the class tag filter pattern * * @param string $className Name of the class to check against * @param string $methodName Name of the method - not used here * @param string $methodDeclaringClassName Name of the class the method was originally declared in - not used here * @param mixed $pointcutQueryIdentifier Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection. * @return boolean TRUE if the class matches, otherwise FALSE * @author Robert Lemke <*****@*****.**> */ public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier) { foreach ($this->reflectionService->getClassTagsValues($className) as $tag => $values) { $matchResult = @preg_match('/^' . $this->classTagFilterExpression . '$/', $tag); if ($matchResult === FALSE) { throw new \F3\FLOW3\AOP\Exception('Error in regular expression "' . $this->classTagFilterExpression . '" in pointcut class tag filter', 1212576034); } if ($matchResult === 1) { return TRUE; } } return FALSE; }
/** * Creates inline comments with annotations which were defined in the target class * * @param string $className Name of the class containing the annotations * @return string PHP code snippet containing the annotations * @author Robert Lemke <*****@*****.**> */ protected function buildClassAnnotationsCode($className) { $annotationsCode = ''; foreach ($this->reflectionService->getClassTagsValues($className) as $tag => $values) { $annotationsCode .= ' * @' . $tag . ' ' . implode(' ', $values) . chr(10); } return $annotationsCode; }
/** * @test * @author Robert Lemke <*****@*****.**> */ public function getClassTagsValuesReturnsArrayOfTagsAndValuesOfAClass() { $availableClassNames = array('F3\\FLOW3\\Tests\\Reflection\\Fixture\\TaggedClass3'); $reflectionService = new \F3\FLOW3\Reflection\ReflectionService(); $reflectionService->setStatusCache($this->getMock('F3\\FLOW3\\Cache\\Frontend\\StringFrontend', array(), array(), '', FALSE)); $reflectionService->setDataCache($this->getMock('F3\\FLOW3\\Cache\\Frontend\\VariableFrontend', array(), array(), '', FALSE)); $reflectionService->injectSystemLogger($this->getMock('F3\\FLOW3\\Log\\SystemLoggerInterface')); $reflectionService->initialize($availableClassNames); $expectedTags = array('firsttag' => array(), 'secondtag' => array('1', '2'), 'thirdtag' => array('one, two', 'three, four')); $detectedTags = $reflectionService->getClassTagsValues('F3\\FLOW3\\Tests\\Reflection\\Fixture\\TaggedClass3'); ksort($detectedTags); $this->assertEquals($expectedTags, $detectedTags); }