Skip to content

Commit

Permalink
ClassReflection::getConstant() - do not crash on unknown declaring class
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Apr 23, 2020
1 parent fb9d320 commit 00e3090
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Reflection/ClassReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 00e3090

Please sign in to comment.