+
diff --git a/src/Reflection/ReflectionClass.php b/src/Reflection/ReflectionClass.php
index 8ba9ba37a..22292e738 100644
--- a/src/Reflection/ReflectionClass.php
+++ b/src/Reflection/ReflectionClass.php
@@ -1086,12 +1086,16 @@ public function getEndColumn(): int
*/
public function getParentClass(): ReflectionClass|null
{
- $parentClass = $this->getParentClasses()[0] ?? null;
-
- if ($parentClass === null) {
+ $parentClassName = $this->getParentClassName();
+ if ($parentClassName === null) {
return null;
}
+ if ($this->name === $parentClassName) {
+ throw CircularReference::fromClassName($parentClassName);
+ }
+
+ $parentClass = $this->reflector->reflectClass($parentClassName);
if ($parentClass->isInterface() || $parentClass->isTrait()) {
throw NotAClassReflection::fromReflectionClass($parentClass);
}