/**
  * Checks if the specified class matches with the class 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 <*****@*****.**>
  * @todo Collect information why class was ignored for debugging in a future AOP browser
  */
 public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier)
 {
     if ($this->reflectionService->isClassFinal($className) || $this->reflectionService->isMethodFinal($className, '__construct')) {
         return FALSE;
     }
     $matchResult = @preg_match('/^' . $this->classFilterExpression . '$/', $className);
     if ($matchResult === FALSE) {
         throw new \F3\FLOW3\AOP\Exception('Error in regular expression "' . $this->classFilterExpression . '" in pointcut class filter', 1168876955);
     }
     return $matchResult === 1;
 }
 /**
  * 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;
 }
 /**
  * Checks if the specified class matches with the class type 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)
 {
     $matches = FALSE;
     foreach ($this->reflectionService->getInterfaceNamesImplementedByClass($className) as $interfaceName) {
         $matchResult = @preg_match('/^' . $this->classTypeFilterExpression . '$/', $interfaceName);
         if ($matchResult === FALSE) {
             throw new \F3\FLOW3\AOP\Exception('Error in regular expression "' . $this->classTypeFilterExpression . '" in pointcut class type filter', 1172483343);
         }
         if ($matchResult === 1) {
             $matches = TRUE;
         }
     }
     return $matches;
 }
 /**
  * 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;
 }
 /**
  * Generates the parameters code needed to call the constructor with the saved parameters.
  *
  * @param string $className Name of the class the method is declared in
  * @return string The generated paramters code
  * @author Andreas Förthner <*****@*****.**>
  */
 protected function buildSavedConstructorParametersCode($className)
 {
     if ($className === NULL) {
         return '';
     }
     $parametersCode = '';
     $methodParameters = $this->reflectionService->getMethodParameters($className, '__construct');
     $methodParametersCount = count($methodParameters);
     if ($methodParametersCount > 0) {
         foreach ($methodParameters as $methodParameterName => $methodParameterInfo) {
             $methodParametersCount--;
             $parametersCode .= '$this->originalConstructorArguments[\'' . $methodParameterName . '\']' . ($methodParametersCount > 0 ? ', ' : '');
         }
     }
     return $parametersCode;
 }
 /**
  * Checks if the specified method matches against the method name
  * expression.
  *
  * @param string $className Ignored in this pointcut filter
  * @param string $methodName Name of the method to match agains
  * @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)
 {
     $matchResult = preg_match('/^' . $this->methodNameFilterExpression . '$/', $methodName);
     if ($matchResult === FALSE) {
         throw new \F3\FLOW3\AOP\Exception('Error in regular expression', 1168876915);
     }
     $methodNameMatches = $matchResult === 1;
     switch ($this->methodVisibility) {
         case 'public':
             $visibilityMatches = $this->reflectionService->isMethodPublic($methodDeclaringClassName, $methodName);
             break;
         case 'protected':
             $visibilityMatches = $this->reflectionService->isMethodProtected($methodDeclaringClassName, $methodName);
             break;
         default:
             $visibilityMatches = TRUE;
     }
     $isNotFinal = $methodDeclaringClassName === NULL || !$this->reflectionService->isMethodFinal($methodDeclaringClassName, $methodName);
     return $methodNameMatches && $visibilityMatches && $isNotFinal;
 }
 /**
  * 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 Karsten Dambekalns <*****@*****.**>
  */
 public function isClassImplementationOfReturnsTrueIfClassImplementsSpecifiedInterface()
 {
     $availableClassNames = array('F3\\FLOW3\\Tests\\Reflection\\Fixture\\ImplementationOfDummyInterface1');
     $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);
     $this->assertTrue($reflectionService->isClassImplementationOf('F3\\FLOW3\\Tests\\Reflection\\Fixture\\ImplementationOfDummyInterface1', 'F3\\FLOW3\\Tests\\Reflection\\Fixture\\DummyInterface1'));
     $this->assertFalse($reflectionService->isClassImplementationOf('F3\\FLOW3\\Tests\\Reflection\\Fixture\\ImplementationOfDummyInterface1', 'F3\\FLOW3\\Tests\\Reflection\\Fixture\\DummyInterface2'));
 }
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function prepareArgumentsRegistersAnnotationBasedArgumentsWithoutDescriptionIfDebugModeIsDisabled()
 {
     \F3\Fluid\Fluid::$debugMode = FALSE;
     $availableClassNames = array('F3\\Fluid\\Core\\Fixtures\\TestViewHelper');
     $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->initialize($availableClassNames);
     $viewHelper = new \F3\Fluid\Core\Fixtures\TestViewHelper();
     $viewHelper->injectReflectionService($reflectionService);
     $expected = array('param1' => new \F3\Fluid\Core\ViewHelper\ArgumentDefinition('param1', 'integer', '', TRUE, null, TRUE), 'param2' => new \F3\Fluid\Core\ViewHelper\ArgumentDefinition('param2', 'array', '', TRUE, null, TRUE), 'param3' => new \F3\Fluid\Core\ViewHelper\ArgumentDefinition('param3', 'string', '', FALSE, 'default', TRUE));
     $this->assertEquals($expected, $viewHelper->prepareArguments(), 'Annotation based arguments were not registered.');
 }