Skip to content

Commit 2bde6b3

Browse files
authored
[Core] Fix undefined constant ReflectionClassConstant::IS_PUBLIC in php 7.x (#1474)
1 parent 77f2def commit 2bde6b3

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/DependencyInjection/Collector/ConfigureCallValuesCollector.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
88
use ReflectionClass;
9-
use ReflectionClassConstant;
109
use Symfony\Component\Console\Style\SymfonyStyle;
1110
use Symfony\Component\DependencyInjection\Definition;
1211
use Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
@@ -68,15 +67,17 @@ private function addConfigureCallValues(string $rectorClass, array $configureVal
6867
// fixes bug when 1 item is unwrapped and treated as constant key, without rule having public constant
6968
$classReflection = new ReflectionClass($rectorClass);
7069

71-
$constantNamesToValues = $classReflection->getConstants(ReflectionClassConstant::IS_PUBLIC);
72-
foreach ($constantNamesToValues as $constantName => $constantValue) {
73-
if ($constantValue === $firstKey) {
74-
$reflectionConstant = $classReflection->getReflectionConstant($constantName);
75-
if ($reflectionConstant === false) {
76-
continue;
77-
}
70+
$reflectionClassConstants = $classReflection->getReflectionConstants();
71+
foreach ($reflectionClassConstants as $reflectionClassConstant) {
72+
if (! $reflectionClassConstant->isPublic()) {
73+
continue;
74+
}
75+
76+
$constantValue = $reflectionClassConstant->getValue();
77+
$constantName = $reflectionClassConstant->getName();
7878

79-
if (! str_contains((string) $reflectionConstant->getDocComment(), '@deprecated')) {
79+
if ($constantValue === $firstKey) {
80+
if (! str_contains((string) $reflectionClassConstant->getDocComment(), '@deprecated')) {
8081
continue;
8182
}
8283

0 commit comments

Comments
 (0)