[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
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-2016 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 use function file_exists; 17 use function md5; 18 use function realpath; 19 use function spl_object_hash; 20 use function sprintf; 21 22 class CachingFileScanner extends FileScanner 23 { 24 /** 25 * @var array 26 */ 27 protected static $cache = []; 28 29 /** 30 * @var null|FileScanner 31 */ 32 protected $fileScanner; 33 34 /** 35 * @param string $file 36 * @param AnnotationManager $annotationManager 37 * @throws Exception\InvalidArgumentException 38 */ 39 public function __construct($file, AnnotationManager $annotationManager = null) 40 { 41 if (! file_exists($file)) { 42 throw new Exception\InvalidArgumentException(sprintf( 43 'File "%s" not found', 44 $file 45 )); 46 } 47 48 $file = realpath($file); 49 50 $cacheId = md5($file) . '/' . (isset($annotationManager) 51 ? spl_object_hash($annotationManager) 52 : 'no-annotation'); 53 54 if (isset(static::$cache[$cacheId])) { 55 $this->fileScanner = static::$cache[$cacheId]; 56 } else { 57 $this->fileScanner = new FileScanner($file, $annotationManager); 58 static::$cache[$cacheId] = $this->fileScanner; 59 } 60 } 61 62 /** 63 * @return void 64 */ 65 public static function clearCache() 66 { 67 static::$cache = []; 68 } 69 70 /** 71 * @return AnnotationManager 72 */ 73 public function getAnnotationManager() 74 { 75 return $this->fileScanner->getAnnotationManager(); 76 } 77 78 /** 79 * @return array|null|string 80 */ 81 public function getFile() 82 { 83 return $this->fileScanner->getFile(); 84 } 85 86 /** 87 * @return null|string 88 */ 89 public function getDocComment() 90 { 91 return $this->fileScanner->getDocComment(); 92 } 93 94 /** 95 * @return array 96 */ 97 public function getNamespaces() 98 { 99 return $this->fileScanner->getNamespaces(); 100 } 101 102 /** 103 * @param null|string $namespace 104 * @return array|null 105 */ 106 public function getUses($namespace = null) 107 { 108 return $this->fileScanner->getUses($namespace); 109 } 110 111 /** 112 * @return array 113 */ 114 public function getIncludes() 115 { 116 return $this->fileScanner->getIncludes(); 117 } 118 119 /** 120 * @return array 121 */ 122 public function getClassNames() 123 { 124 return $this->fileScanner->getClassNames(); 125 } 126 127 /** 128 * @return array 129 */ 130 public function getClasses() 131 { 132 return $this->fileScanner->getClasses(); 133 } 134 135 /** 136 * @param int|string $className 137 * @return ClassScanner 138 */ 139 public function getClass($className) 140 { 141 return $this->fileScanner->getClass($className); 142 } 143 144 /** 145 * @param string $className 146 * @return bool|null|NameInformation 147 */ 148 public function getClassNameInformation($className) 149 { 150 return $this->fileScanner->getClassNameInformation($className); 151 } 152 153 /** 154 * @return array 155 */ 156 public function getFunctionNames() 157 { 158 return $this->fileScanner->getFunctionNames(); 159 } 160 161 /** 162 * @return array 163 */ 164 public function getFunctions() 165 { 166 return $this->fileScanner->getFunctions(); 167 } 168 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |