Source of file CachingFileScanner.php
Size: 3,525 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Code/Scanner/CachingFileScanner.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Code\Scanner; use Zend\Code\Annotation\AnnotationManager; use Zend\Code\Exception; use Zend\Code\NameInformation; class CachingFileScanner extends FileScanner { /** * @var array */ protected static $cache = array(); /** * @var null|FileScanner */ protected $fileScanner = null; /** * @param array|null $file * @param AnnotationManager $annotationManager * @throws Exception\InvalidArgumentException */ public function __construct($file, AnnotationManager $annotationManager = null) { if (!file_exists($file)) { throw new Exception\InvalidArgumentException(sprintf( 'File "%s" not found', $file )); } $file = realpath($file); $cacheId = md5($file) . '/' . ((isset($annotationManager) ? spl_object_hash($annotationManager) : 'no-annotation')); if (isset(static::$cache[$cacheId])) { $this->fileScanner = static::$cache[$cacheId]; } else { $this->fileScanner = new FileScanner($file, $annotationManager); static::$cache[$cacheId] = $this->fileScanner; } } /** * @return void */ public static function clearCache() { static::$cache = array(); } /** * @return AnnotationManager */ public function getAnnotationManager() { return $this->fileScanner->getAnnotationManager(); } /** * @return array|null|string */ public function getFile() { return $this->fileScanner->getFile(); } /** * @return null|string */ public function getDocComment() { return $this->fileScanner->getDocComment(); } /** * @return array */ public function getNamespaces() { return $this->fileScanner->getNamespaces(); } /** * @param null|string $namespace * @return array|null */ public function getUses($namespace = null) { return $this->fileScanner->getUses($namespace); } /** * @return array */ public function getIncludes() { return $this->fileScanner->getIncludes(); } /** * @return array */ public function getClassNames() { return $this->fileScanner->getClassNames(); } /** * @return array */ public function getClasses() { return $this->fileScanner->getClasses(); } /** * @param int|string $className * @return ClassScanner */ public function getClass($className) { return $this->fileScanner->getClass($className); } /** * @param string $className * @return bool|null|NameInformation */ public function getClassNameInformation($className) { return $this->fileScanner->getClassNameInformation($className); } /** * @return array */ public function getFunctionNames() { return $this->fileScanner->getFunctionNames(); } /** * @return array */ public function getFunctions() { return $this->fileScanner->getFunctions(); } } |