Skip to content

Commit a6a8752

Browse files
authored
Ensure native ReflectionClassConstant->isFinal() exists by check real php version (#7171)
1 parent f78209f commit a6a8752

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,13 @@ private function shouldSkip(
179179
$nativeReflectionClass = $declaringClass->getNativeReflection();
180180
$constantName = $reflection->getName();
181181

182-
if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::FINAL_CLASS_CONSTANTS)) {
182+
if (
183+
// by feature config
184+
$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::FINAL_CLASS_CONSTANTS) &&
185+
// ensure native ->isFinal() exists
186+
// @see https://3v4l.org/korKr#v8.0.11
187+
PHP_VERSION_ID >= PhpVersionFeature::FINAL_CLASS_CONSTANTS
188+
) {
183189
// PHP 8.1+
184190
$nativeReflection = $nativeReflectionClass->getReflectionConstant($constantName);
185191
$memberIsFinal = $nativeReflection instanceof ReflectionClassConstant && $nativeReflection->isFinal();

0 commit comments

Comments
 (0)