Zend\Code\Scanner\ClassScanner::getConstants PHP Method

getConstants() public method

Return a list of constants
public getConstants ( boolean $namesOnly = true ) : array | Zend\Code\Scanner\ConstantScanner[]
$namesOnly boolean Set false to return instances of ConstantScanner
return array | Zend\Code\Scanner\ConstantScanner[]
    public function getConstants($namesOnly = true)
    {
        if (true === $namesOnly) {
            trigger_error('Use method getConstantNames() instead', E_USER_DEPRECATED);
            return $this->getConstantNames();
        }
        $this->scan();
        $return = [];
        foreach ($this->infos as $info) {
            if ($info['type'] != 'constant') {
                continue;
            }
            $return[] = $this->getConstant($info['name']);
        }
        return $return;
    }

Usage Example

 /**
  * @return array
  */
 public function getConstants()
 {
     $constants = $this->classScanner->getConstants();
     foreach ($this->parentClassScanners as $pClassScanner) {
         $constants = array_merge($constants, $pClassScanner->getConstants());
     }
     return $constants;
 }
All Usage Examples Of Zend\Code\Scanner\ClassScanner::getConstants