From fb136bad9779696ddcb958f14a8ccd4cc3a83a4d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Aug 2025 13:42:36 +0700 Subject: [PATCH] Ensure native ReflectionClassConstant->isFinal() exists by check real php version --- .../Rector/Class_/ConvertStaticToSelfRector.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php b/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php index a83cf169ba0..fb12cebc991 100644 --- a/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php +++ b/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php @@ -179,7 +179,13 @@ private function shouldSkip( $nativeReflectionClass = $declaringClass->getNativeReflection(); $constantName = $reflection->getName(); - if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::FINAL_CLASS_CONSTANTS)) { + if ( + // by feature config + $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::FINAL_CLASS_CONSTANTS) && + // ensure native ->isFinal() exists + // @see https://3v4l.org/korKr#v8.0.11 + PHP_VERSION_ID >= PhpVersionFeature::FINAL_CLASS_CONSTANTS + ) { // PHP 8.1+ $nativeReflection = $nativeReflectionClass->getReflectionConstant($constantName); $memberIsFinal = $nativeReflection instanceof ReflectionClassConstant && $nativeReflection->isFinal();