diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a42412d79..ebbe9d5a5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -100,6 +100,7 @@ + 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); }