예제 #1
0
 private function parseType($annotations, TokenReflectionClass $tokenizedClass)
 {
     $currentNamespace = $tokenizedClass->getNamespaceName();
     $currentNamespaceAliases = $tokenizedClass->getNamespaceAliases();
     foreach ($annotations as $annotation) {
         preg_match(self::TYPE_REGEXP, $annotation, $matches);
         if (!empty($matches[0])) {
             list($parsedNamespace, $parsedClassName) = $this->parseClass($matches[0]);
             if ($this->isIgnoredType($parsedClassName)) {
                 continue;
             }
             if (empty($parsedNamespace) && isset($currentNamespaceAliases[$parsedClassName])) {
                 return $currentNamespaceAliases[$parsedClassName];
             } else {
                 if (isset($currentNamespaceAliases[$parsedNamespace])) {
                     return $currentNamespaceAliases[$parsedNamespace] . '\\' . $parsedClassName;
                 } else {
                     if (class_exists($currentNamespace . '\\' . $parsedClassName)) {
                         return $currentNamespace . '\\' . $parsedClassName;
                     } else {
                         if (class_exists($parsedClassName)) {
                             return $parsedClassName;
                         }
                     }
                 }
             }
         }
     }
     return null;
 }
예제 #2
0
 public function getInheritanceTree()
 {
     $parent_entries = [];
     $parents = $this->reflection->getParentClassNameList();
     $currentNamespace = $this->reflection->getNamespaceName();
     if (!empty($parents)) {
         foreach ($parents as $key => $parent) {
             $string = ':ref:`';
             $string .= str_replace('\\', '-', $parent) . "`";
             $parent_entries[] = $string;
         }
     } else {
         return "";
     }
     $refs = join(' => ', $parent_entries);
     $title = "**Inheritance Hierarchy:**\n";
     return "{$title}{$refs}\n\n";
 }
예제 #3
0
 /**
  * Save AOP proxy to the separate file anr returns the php source code for inclusion
  *
  * @param ParsedClass $class Original class reflection
  * @param string|ClassProxy $child
  *
  * @return string
  */
 private function saveProxyToCache($class, $child)
 {
     // Without cache we should rewrite original file
     if (empty($this->options['cacheDir'])) {
         return $child;
     }
     $cacheDirSuffix = '/_proxies/';
     $cacheDir = $this->options['cacheDir'] . $cacheDirSuffix;
     $fileName = str_replace('\\', '/', $class->getName()) . '.php';
     $proxyFileName = $cacheDir . $fileName;
     $dirname = dirname($proxyFileName);
     if (!file_exists($dirname)) {
         mkdir($dirname, 0770, true);
     }
     $body = '<?php' . PHP_EOL;
     $namespace = $class->getNamespaceName();
     if ($namespace) {
         $body .= "namespace {$namespace};" . PHP_EOL . PHP_EOL;
     }
     foreach ($class->getNamespaceAliases() as $alias => $fqdn) {
         $body .= "use {$fqdn} as {$alias};" . PHP_EOL;
     }
     $body .= $child;
     file_put_contents($proxyFileName, $body);
     return 'include_once AOP_CACHE_DIR . ' . var_export($cacheDirSuffix . $fileName, true) . ';' . PHP_EOL;
 }
예제 #4
0
 public function getNamespaceElement()
 {
     return '.. php:namespace: ' . str_replace('\\', '\\\\', $this->reflection->getNamespaceName()) . "\n\n";
 }