BetterReflection\Reflection\ReflectionClass::getConstants PHP Method

getConstants() public method

Get an array of the defined constants in this class.
public getConstants ( ) : mixed[]
return mixed[]
    public function getConstants()
    {
        if (null !== $this->cachedConstants) {
            return $this->cachedConstants;
        }
        $constants = [];
        foreach ($this->node->stmts as $stmt) {
            if ($stmt instanceof ConstNode) {
                $constName = $stmt->consts[0]->name;
                $constValue = (new CompileNodeToValue())->__invoke($stmt->consts[0]->value, new CompilerContext($this->reflector, $this));
                $constants[$constName] = $constValue;
            }
        }
        $this->cachedConstants = $constants;
        return $constants;
    }

Usage Example

 /**
  * {@inheritDoc}
  */
 public function getConstants()
 {
     return $this->betterReflectionClass->getConstants();
 }
All Usage Examples Of BetterReflection\Reflection\ReflectionClass::getConstants