/**
  * This method is used to optimize the matching process.
  *
  * @param \TYPO3\Flow\Aop\Builder\ClassNameIndex $classNameIndex
  * @return \TYPO3\Flow\Aop\Builder\ClassNameIndex
  */
 public function reduceTargetClassNames(\TYPO3\Flow\Aop\Builder\ClassNameIndex $classNameIndex)
 {
     $classNames = $this->reflectionService->getClassesContainingMethodsAnnotatedWith($this->annotation);
     $annotatedIndex = new \TYPO3\Flow\Aop\Builder\ClassNameIndex();
     $annotatedIndex->setClassNames($classNames);
     return $classNameIndex->intersect($annotatedIndex);
 }
 /**
  * Compile the result of methods marked with CompileStatic into the proxy class
  *
  * @param string $className
  * @param \TYPO3\Flow\Object\Proxy\ProxyClass $proxyClass
  * @return void
  */
 protected function compileStaticMethods($className, $proxyClass)
 {
     if ($this->classesWithCompileStaticAnnotation === null) {
         $this->classesWithCompileStaticAnnotation = array_flip($this->reflectionService->getClassesContainingMethodsAnnotatedWith(\TYPO3\Flow\Annotations\CompileStatic::class));
     }
     if (!isset($this->classesWithCompileStaticAnnotation[$className])) {
         return;
     }
     $methodNames = get_class_methods($className);
     foreach ($methodNames as $methodName) {
         if ($this->reflectionService->isMethodStatic($className, $methodName) && $this->reflectionService->isMethodAnnotatedWith($className, $methodName, \TYPO3\Flow\Annotations\CompileStatic::class)) {
             $compiledMethod = $proxyClass->getMethod($methodName);
             $value = call_user_func(array($className, $methodName), $this->objectManager);
             $compiledResult = var_export($value, true);
             $compiledMethod->setMethodBody('return ' . $compiledResult . ';');
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @param array $classesSelector
  * @return array
  */
 protected function getAffectedClassNames(array $classesSelector)
 {
     if (isset($classesSelector['parentClassName'])) {
         $affectedClassNames = $this->reflectionService->getAllSubClassNamesForClass($classesSelector['parentClassName']);
     } elseif (isset($classesSelector['interface'])) {
         $affectedClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface($classesSelector['interface']);
     } elseif (isset($classesSelector['classesContainingMethodsAnnotatedWith'])) {
         $affectedClassNames = $this->reflectionService->getClassesContainingMethodsAnnotatedWith($classesSelector['classesContainingMethodsAnnotatedWith']);
     } else {
         $affectedClassNames = $this->reflectionService->getAllClassNames();
     }
     foreach ($affectedClassNames as $index => $className) {
         if ($this->reflectionService->isClassAbstract($className) && (!isset($classesSelector['includeAbstractClasses']) || $classesSelector['includeAbstractClasses'] === FALSE)) {
             unset($affectedClassNames[$index]);
         } elseif (isset($classesSelector['classNamePattern']) && preg_match($classesSelector['classNamePattern'], $className) === 0) {
             unset($affectedClassNames[$index]);
         }
     }
     return $affectedClassNames;
 }