[ Index ] |
PHP Cross Reference of phpBB-3.2.11-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-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\Exception; 13 14 class DerivedClassScanner extends ClassScanner 15 { 16 /** 17 * @var DirectoryScanner 18 */ 19 protected $directoryScanner = null; 20 21 /** 22 * @var ClassScanner 23 */ 24 protected $classScanner = null; 25 26 /** 27 * @var array 28 */ 29 protected $parentClassScanners = array(); 30 31 /** 32 * @var array 33 */ 34 protected $interfaceClassScanners = array(); 35 36 /** 37 * @param ClassScanner $classScanner 38 * @param DirectoryScanner $directoryScanner 39 */ 40 public function __construct(ClassScanner $classScanner, DirectoryScanner $directoryScanner) 41 { 42 $this->classScanner = $classScanner; 43 $this->directoryScanner = $directoryScanner; 44 45 $currentScannerClass = $classScanner; 46 47 while ($currentScannerClass && $currentScannerClass->hasParentClass()) { 48 $currentParentClassName = $currentScannerClass->getParentClass(); 49 if ($directoryScanner->hasClass($currentParentClassName)) { 50 $currentParentClass = $directoryScanner->getClass($currentParentClassName); 51 $this->parentClassScanners[$currentParentClassName] = $currentParentClass; 52 $currentScannerClass = $currentParentClass; 53 } else { 54 $currentScannerClass = false; 55 } 56 } 57 58 foreach ($interfaces = $this->classScanner->getInterfaces() as $iName) { 59 if ($directoryScanner->hasClass($iName)) { 60 $this->interfaceClassScanners[$iName] = $directoryScanner->getClass($iName); 61 } 62 } 63 } 64 65 /** 66 * @return null|string 67 */ 68 public function getName() 69 { 70 return $this->classScanner->getName(); 71 } 72 73 /** 74 * @return null|string 75 */ 76 public function getShortName() 77 { 78 return $this->classScanner->getShortName(); 79 } 80 81 /** 82 * @return bool 83 */ 84 public function isInstantiable() 85 { 86 return $this->classScanner->isInstantiable(); 87 } 88 89 /** 90 * @return bool 91 */ 92 public function isFinal() 93 { 94 return $this->classScanner->isFinal(); 95 } 96 97 /** 98 * @return bool 99 */ 100 public function isAbstract() 101 { 102 return $this->classScanner->isAbstract(); 103 } 104 105 /** 106 * @return bool 107 */ 108 public function isInterface() 109 { 110 return $this->classScanner->isInterface(); 111 } 112 113 /** 114 * @return array 115 */ 116 public function getParentClasses() 117 { 118 return array_keys($this->parentClassScanners); 119 } 120 121 /** 122 * @return bool 123 */ 124 public function hasParentClass() 125 { 126 return ($this->classScanner->getParentClass() !== null); 127 } 128 129 /** 130 * @return null|string 131 */ 132 public function getParentClass() 133 { 134 return $this->classScanner->getParentClass(); 135 } 136 137 /** 138 * @param bool $returnClassScanners 139 * @return array 140 */ 141 public function getInterfaces($returnClassScanners = false) 142 { 143 if ($returnClassScanners) { 144 return $this->interfaceClassScanners; 145 } 146 147 $interfaces = $this->classScanner->getInterfaces(); 148 foreach ($this->parentClassScanners as $pClassScanner) { 149 $interfaces = array_merge($interfaces, $pClassScanner->getInterfaces()); 150 } 151 152 return $interfaces; 153 } 154 155 /** 156 * Return a list of constant names 157 * 158 * @return array 159 */ 160 public function getConstantNames() 161 { 162 $constants = $this->classScanner->getConstantNames(); 163 foreach ($this->parentClassScanners as $pClassScanner) { 164 $constants = array_merge($constants, $pClassScanner->getConstantNames()); 165 } 166 167 return $constants; 168 } 169 170 /** 171 * Return a list of constants 172 * 173 * @param bool $namesOnly Set false to return instances of ConstantScanner 174 * @return array|ConstantScanner[] 175 */ 176 public function getConstants($namesOnly = true) 177 { 178 if (true === $namesOnly) { 179 trigger_error('Use method getConstantNames() instead', E_USER_DEPRECATED); 180 return $this->getConstantNames(); 181 } 182 183 $constants = $this->classScanner->getConstants(); 184 foreach ($this->parentClassScanners as $pClassScanner) { 185 $constants = array_merge($constants, $pClassScanner->getConstants($namesOnly)); 186 } 187 188 return $constants; 189 } 190 191 /** 192 * Return a single constant by given name or index of info 193 * 194 * @param string|int $constantNameOrInfoIndex 195 * @throws Exception\InvalidArgumentException 196 * @return bool|ConstantScanner 197 */ 198 public function getConstant($constantNameOrInfoIndex) 199 { 200 if ($this->classScanner->hasConstant($constantNameOrInfoIndex)) { 201 return $this->classScanner->getConstant($constantNameOrInfoIndex); 202 } 203 204 foreach ($this->parentClassScanners as $pClassScanner) { 205 if ($pClassScanner->hasConstant($constantNameOrInfoIndex)) { 206 return $pClassScanner->getConstant($constantNameOrInfoIndex); 207 } 208 } 209 210 throw new Exception\InvalidArgumentException(sprintf( 211 'Constant %s not found in %s', 212 $constantNameOrInfoIndex, 213 $this->classScanner->getName() 214 )); 215 } 216 217 /** 218 * Verify if class or parent class has constant 219 * 220 * @param string $name 221 * @return bool 222 */ 223 public function hasConstant($name) 224 { 225 if ($this->classScanner->hasConstant($name)) { 226 return true; 227 } 228 foreach ($this->parentClassScanners as $pClassScanner) { 229 if ($pClassScanner->hasConstant($name)) { 230 return true; 231 } 232 } 233 234 return false; 235 } 236 237 /** 238 * Return a list of property names 239 * 240 * @return array 241 */ 242 public function getPropertyNames() 243 { 244 $properties = $this->classScanner->getPropertyNames(); 245 foreach ($this->parentClassScanners as $pClassScanner) { 246 $properties = array_merge($properties, $pClassScanner->getPropertyNames()); 247 } 248 249 return $properties; 250 } 251 252 /** 253 * @param bool $returnScannerProperty 254 * @return array 255 */ 256 public function getProperties($returnScannerProperty = false) 257 { 258 $properties = $this->classScanner->getProperties($returnScannerProperty); 259 foreach ($this->parentClassScanners as $pClassScanner) { 260 $properties = array_merge($properties, $pClassScanner->getProperties($returnScannerProperty)); 261 } 262 263 return $properties; 264 } 265 266 /** 267 * Return a single property by given name or index of info 268 * 269 * @param string|int $propertyNameOrInfoIndex 270 * @throws Exception\InvalidArgumentException 271 * @return bool|PropertyScanner 272 */ 273 public function getProperty($propertyNameOrInfoIndex) 274 { 275 if ($this->classScanner->hasProperty($propertyNameOrInfoIndex)) { 276 return $this->classScanner->getProperty($propertyNameOrInfoIndex); 277 } 278 279 foreach ($this->parentClassScanners as $pClassScanner) { 280 if ($pClassScanner->hasProperty($propertyNameOrInfoIndex)) { 281 return $pClassScanner->getProperty($propertyNameOrInfoIndex); 282 } 283 } 284 285 throw new Exception\InvalidArgumentException(sprintf( 286 'Property %s not found in %s', 287 $propertyNameOrInfoIndex, 288 $this->classScanner->getName() 289 )); 290 } 291 292 /** 293 * Verify if class or parent class has property 294 * 295 * @param string $name 296 * @return bool 297 */ 298 public function hasProperty($name) 299 { 300 if ($this->classScanner->hasProperty($name)) { 301 return true; 302 } 303 foreach ($this->parentClassScanners as $pClassScanner) { 304 if ($pClassScanner->hasProperty($name)) { 305 return true; 306 } 307 } 308 309 return false; 310 } 311 312 /** 313 * @return array 314 */ 315 public function getMethodNames() 316 { 317 $methods = $this->classScanner->getMethodNames(); 318 foreach ($this->parentClassScanners as $pClassScanner) { 319 $methods = array_merge($methods, $pClassScanner->getMethodNames()); 320 } 321 322 return $methods; 323 } 324 325 /** 326 * @return MethodScanner[] 327 */ 328 public function getMethods() 329 { 330 $methods = $this->classScanner->getMethods(); 331 foreach ($this->parentClassScanners as $pClassScanner) { 332 $methods = array_merge($methods, $pClassScanner->getMethods()); 333 } 334 335 return $methods; 336 } 337 338 /** 339 * @param int|string $methodNameOrInfoIndex 340 * @return MethodScanner 341 * @throws Exception\InvalidArgumentException 342 */ 343 public function getMethod($methodNameOrInfoIndex) 344 { 345 if ($this->classScanner->hasMethod($methodNameOrInfoIndex)) { 346 return $this->classScanner->getMethod($methodNameOrInfoIndex); 347 } 348 349 foreach ($this->parentClassScanners as $pClassScanner) { 350 if ($pClassScanner->hasMethod($methodNameOrInfoIndex)) { 351 return $pClassScanner->getMethod($methodNameOrInfoIndex); 352 } 353 } 354 355 throw new Exception\InvalidArgumentException(sprintf( 356 'Method %s not found in %s', 357 $methodNameOrInfoIndex, 358 $this->classScanner->getName() 359 )); 360 } 361 362 /** 363 * Verify if class or parent class has method by given name 364 * 365 * @param string $name 366 * @return bool 367 */ 368 public function hasMethod($name) 369 { 370 if ($this->classScanner->hasMethod($name)) { 371 return true; 372 } 373 foreach ($this->parentClassScanners as $pClassScanner) { 374 if ($pClassScanner->hasMethod($name)) { 375 return true; 376 } 377 } 378 379 return false; 380 } 381 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |