From 00e3090d373a63583bfaab95afd79c7de0703a94 Mon Sep 17 00:00:00 2001
From: Ondrej Mirtes <ondrej@mirtes.cz>
Date: Thu, 23 Apr 2020 19:11:46 +0200
Subject: [PATCH] ClassReflection::getConstant() - do not crash on unknown
 declaring class

---
 src/Reflection/ClassReflection.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/Reflection/ClassReflection.php b/src/Reflection/ClassReflection.php
index 573a2d09ba..5c2d2f69e8 100644
--- a/src/Reflection/ClassReflection.php
+++ b/src/Reflection/ClassReflection.php
@@ -608,7 +608,13 @@ public function getParentClassesNames(): array
 
 	public function hasConstant(string $name): bool
 	{
-		return $this->getNativeReflection()->hasConstant($name);
+		if (!$this->getNativeReflection()->hasConstant($name)) {
+			return false;
+		}
+
+		$reflectionConstant = $this->getNativeReflection()->getReflectionConstant($name);
+
+		return $this->reflectionProvider->hasClass($reflectionConstant->getDeclaringClass()->getName());
 	}
 
 	public function getConstant(string $name): ConstantReflection