> */ private $cachedConstantNamesToValues = []; /** * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } /** * @return array */ public function getClassConstantNamesToValues(string $classWithConstants) : array { if (isset($this->cachedConstantNamesToValues[$classWithConstants])) { return $this->cachedConstantNamesToValues[$classWithConstants]; } if (!$this->reflectionProvider->hasClass($classWithConstants)) { return []; } $classReflection = $this->reflectionProvider->getClass($classWithConstants); $reflectionClass = $classReflection->getNativeReflection(); $constantNamesToValues = $reflectionClass->getConstants(); $this->cachedConstantNamesToValues = $constantNamesToValues; return $constantNamesToValues; } }