Skip to content

Commit 82e7863

Browse files
committed
Revert [Core] Fix undefined constant ReflectionClassConstant::IS_PUBLIC in php 7.x
This reverts commit 2bde6b3.
1 parent 7117ee1 commit 82e7863

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/DependencyInjection/Collector/ConfigureCallValuesCollector.php

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

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

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();
78-
71+
$constantNamesToValues = $classReflection->getConstants(ReflectionClassConstant::IS_PUBLIC);
72+
foreach ($constantNamesToValues as $constantName => $constantValue) {
7973
if ($constantValue === $firstKey) {
80-
if (! str_contains((string) $reflectionClassConstant->getDocComment(), '@deprecated')) {
74+
$reflectionConstant = $classReflection->getReflectionConstant($constantName);
75+
if ($reflectionConstant === false) {
76+
continue;
77+
}
78+
79+
if (! str_contains((string) $reflectionConstant->getDocComment(), '@deprecated')) {
8180
continue;
8281
}
8382

0 commit comments

Comments
 (0)