[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/zendframework/zend-code/src/Scanner/ -> CachingFileScanner.php (source)

   1  <?php
   2  /**
   3   * Zend Framework (http://framework.zend.com/)
   4   *
   5   * @link      http://github.com/zendframework/zf2 for the canonical source repository
   6   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
   7   * @license   http://framework.zend.com/license/new-bsd New BSD License
   8   */
   9  
  10  namespace Zend\Code\Scanner;
  11  
  12  use Zend\Code\Annotation\AnnotationManager;
  13  use Zend\Code\Exception;
  14  use Zend\Code\NameInformation;
  15  
  16  class CachingFileScanner extends FileScanner
  17  {
  18      /**
  19       * @var array
  20       */
  21      protected static $cache = array();
  22  
  23      /**
  24       * @var null|FileScanner
  25       */
  26      protected $fileScanner = null;
  27  
  28      /**
  29       * @param  string $file
  30       * @param  AnnotationManager $annotationManager
  31       * @throws Exception\InvalidArgumentException
  32       */
  33      public function __construct($file, AnnotationManager $annotationManager = null)
  34      {
  35          if (!file_exists($file)) {
  36              throw new Exception\InvalidArgumentException(sprintf(
  37                  'File "%s" not found',
  38                  $file
  39              ));
  40          }
  41  
  42          $file = realpath($file);
  43  
  44          $cacheId = md5($file) . '/' . ((isset($annotationManager) ? spl_object_hash($annotationManager) : 'no-annotation'));
  45  
  46          if (isset(static::$cache[$cacheId])) {
  47              $this->fileScanner = static::$cache[$cacheId];
  48          } else {
  49              $this->fileScanner       = new FileScanner($file, $annotationManager);
  50              static::$cache[$cacheId] = $this->fileScanner;
  51          }
  52      }
  53  
  54      /**
  55       * @return void
  56       */
  57      public static function clearCache()
  58      {
  59          static::$cache = array();
  60      }
  61  
  62      /**
  63       * @return AnnotationManager
  64       */
  65      public function getAnnotationManager()
  66      {
  67          return $this->fileScanner->getAnnotationManager();
  68      }
  69  
  70      /**
  71       * @return array|null|string
  72       */
  73      public function getFile()
  74      {
  75          return $this->fileScanner->getFile();
  76      }
  77  
  78      /**
  79       * @return null|string
  80       */
  81      public function getDocComment()
  82      {
  83          return $this->fileScanner->getDocComment();
  84      }
  85  
  86      /**
  87       * @return array
  88       */
  89      public function getNamespaces()
  90      {
  91          return $this->fileScanner->getNamespaces();
  92      }
  93  
  94      /**
  95       * @param  null|string $namespace
  96       * @return array|null
  97       */
  98      public function getUses($namespace = null)
  99      {
 100          return $this->fileScanner->getUses($namespace);
 101      }
 102  
 103      /**
 104       * @return array
 105       */
 106      public function getIncludes()
 107      {
 108          return $this->fileScanner->getIncludes();
 109      }
 110  
 111      /**
 112       * @return array
 113       */
 114      public function getClassNames()
 115      {
 116          return $this->fileScanner->getClassNames();
 117      }
 118  
 119      /**
 120       * @return array
 121       */
 122      public function getClasses()
 123      {
 124          return $this->fileScanner->getClasses();
 125      }
 126  
 127      /**
 128       * @param  int|string $className
 129       * @return ClassScanner
 130       */
 131      public function getClass($className)
 132      {
 133          return $this->fileScanner->getClass($className);
 134      }
 135  
 136      /**
 137       * @param  string $className
 138       * @return bool|null|NameInformation
 139       */
 140      public function getClassNameInformation($className)
 141      {
 142          return $this->fileScanner->getClassNameInformation($className);
 143      }
 144  
 145      /**
 146       * @return array
 147       */
 148      public function getFunctionNames()
 149      {
 150          return $this->fileScanner->getFunctionNames();
 151      }
 152  
 153      /**
 154       * @return array
 155       */
 156      public function getFunctions()
 157      {
 158          return $this->fileScanner->getFunctions();
 159      }
 160  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1