/** * Checks if the specified method matches with the method 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 * @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) { if ($methodDeclaringClassName === NULL) { return FALSE; } foreach ($this->reflectionService->getMethodTagsValues($methodDeclaringClassName, $methodName) as $tag => $values) { $matchResult = @preg_match('/^' . $this->methodTagFilterExpression . '$/', $tag); if ($matchResult === FALSE) { throw new \F3\FLOW3\AOP\Exception('Error in regular expression "' . $this->methodTagFilterExpression . '" in pointcut method tag filter', 1229343988); } if ($matchResult === 1) { return TRUE; } } return FALSE; }
/** * /** * Builds the method docblock for the specified method keeping the vital * annotations to be used in a method interceptor in the proxy class. * * @param string $className Name of the class the method is declared in * @param string $methodName Name of the method to create the parameters code for * @return string $methodDocumentation Passed by reference, will contain the DocComment for the given method * @author Karsten Dambekalns <*****@*****.**> */ public function buildMethodDocumentation($className, $methodName) { if ($className === NULL || $methodName === NULL) { return ''; } $methodDocumentation = ''; $methodTags = $this->reflectionService->getMethodTagsValues($className, $methodName); $ignoredTags = $this->reflectionService->getIgnoredTags(); foreach ($methodTags as $tag => $values) { if (!in_array($tag, $ignoredTags)) { foreach ($values as $value) { $methodDocumentation .= chr(10) . chr(9) . ' * @' . $tag . ' ' . $value; } } } return $methodDocumentation; }
/** * Register method arguments for "render" by analysing the doc comment above. * * @return void * @author Sebastian Kurfürst <*****@*****.**> * @author Bastian Waidelich <*****@*****.**> */ private function registerRenderMethodArguments() { $methodParameters = $this->reflectionService->getMethodParameters(get_class($this), 'render'); if (count($methodParameters) === 0) { return; } if (\F3\Fluid\Fluid::$debugMode) { $methodTags = $this->reflectionService->getMethodTagsValues(get_class($this), 'render'); $paramAnnotations = array(); if (isset($methodTags['param'])) { $paramAnnotations = $methodTags['param']; } } $i = 0; foreach ($methodParameters as $parameterName => $parameterInfo) { $dataType = NULL; if (isset($parameterInfo['type'])) { $dataType = $parameterInfo['type']; } elseif ($parameterInfo['array']) { $dataType = 'array'; } if ($dataType === NULL) { throw new \F3\Fluid\Core\Parser\Exception('could not determine type of argument "' . $parameterName . '" of the render-method in ViewHelper "' . get_class($this) . '". Either the methods docComment is invalid or some PHP optimizer strips off comments.', 1242292003); } $description = ''; if (\F3\Fluid\Fluid::$debugMode && isset($paramAnnotations[$i])) { $explodedAnnotation = explode(' ', $paramAnnotations[$i]); array_shift($explodedAnnotation); array_shift($explodedAnnotation); $description = implode(' ', $explodedAnnotation); } $defaultValue = NULL; if (isset($parameterInfo['defaultValue'])) { $defaultValue = $parameterInfo['defaultValue']; } $this->argumentDefinitions[$parameterName] = new \F3\Fluid\Core\ViewHelper\ArgumentDefinition($parameterName, $dataType, $description, $parameterInfo['optional'] === FALSE, $defaultValue, TRUE); $i++; } }
/** * @test * @author Robert Lemke <*****@*****.**> */ public function getMethodTagsValuesReturnsArrayOfTagsAndValuesOfAMethod() { $availableClassNames = array('F3\\FLOW3\\Tests\\Reflection\\Fixture\\DummyClassWithMethods'); $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(), 'return' => array('void'), 'secondtag' => array('a', 'b'), 'param' => array('string $arg1 Argument 1 documentation')); $detectedTags = $reflectionService->getMethodTagsValues('F3\\FLOW3\\Tests\\Reflection\\Fixture\\DummyClassWithMethods', 'firstMethod'); ksort($detectedTags); $this->assertEquals($expectedTags, $detectedTags); }