Skip to content

Commit

Permalink
Fix ReflectionSourceStubber compatibility before PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Mar 23, 2024
1 parent 9a3ec98 commit 94ca133
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/SourceLocator/SourceStubber/ReflectionSourceStubber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Roave\BetterReflection\SourceLocator\SourceStubber;

use BackedEnum;
use LogicException;
use PhpParser\Builder\Class_;
use PhpParser\Builder\ClassConst;
Expand Down Expand Up @@ -297,7 +298,11 @@ private function addExtendsAndImplements(Class_|Interface_|Enum_ $classNode, Cor
}

foreach ($interfaces as $interfaceName) {
if ($classReflection->isEnum() && in_array($interfaceName, [BackedEnum::class, UnitEnum::class], true)) {
if (
method_exists($classReflection, 'isEnum')
&& $classReflection->isEnum()
&& in_array($interfaceName, [BackedEnum::class, UnitEnum::class], true)
) {
continue;
}

Expand Down

0 comments on commit 94ca133

Please sign in to comment.