Return a list of constants
public getConstants ( boolean $namesOnly = true ) : array | Zend\Code\Scanner\ConstantScanner[] | ||
$namesOnly | boolean | Set false to return instances of ConstantScanner |
Результат | array | Zend\Code\Scanner\ConstantScanner[] |
/** * @return array */ public function getConstants() { $constants = $this->classScanner->getConstants(); foreach ($this->parentClassScanners as $pClassScanner) { $constants = array_merge($constants, $pClassScanner->getConstants()); } return $constants; }
/** * Return a list of constants * * @param bool $namesOnly Set false to return instances of ConstantScanner * @return array|ConstantScanner[] */ public function getConstants($namesOnly = true) { if (true === $namesOnly) { trigger_error('Use method getConstantNames() instead', E_USER_DEPRECATED); return $this->getConstantNames(); } $constants = $this->classScanner->getConstants(); foreach ($this->parentClassScanners as $pClassScanner) { $constants = array_merge($constants, $pClassScanner->getConstants($namesOnly)); } return $constants; }
/** * Retrieve class footprint from class scanner * * @param ClassScanner $class * * @return ClassFootprint */ protected function getClassFootprint(ClassScanner $class) { $footprint = new ClassFootprint(); if ($class->isInterface()) { $footprint->setType(ClassFootprint::TYPE_INTERFACE); } elseif ($class->isTrait()) { $footprint->setType(ClassFootprint::TYPE_TRAIT); } $footprint->setParent($class->getParentClass()); foreach ($class->getConstants(false) as $constant) { $footprint->addConstant($constant->getName(), $constant->getValue()); } foreach ($class->getInterfaces() as $interface) { $footprint->addInterface($interface); } return $footprint; }