diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index f320d428e5d..6b5f8e0a30d 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -9,7 +9,7 @@ ], "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.38" + "phpstan/phpstan": "^2.1.40" }, "autoload": { "files": [ diff --git a/composer.json b/composer.json index 4a2bd6795db..48122114326 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "nikic/php-parser": "^5.7", "ondram/ci-detector": "^4.2", "phpstan/phpdoc-parser": "^2.3", - "phpstan/phpstan": "^2.1.38", + "phpstan/phpstan": "^2.1.40", "react/event-loop": "^1.6", "react/promise": "^3.3", "react/socket": "^1.17", diff --git a/rules-tests/CodeQuality/Rector/ClassConstFetch/VariableConstFetchToClassConstFetchRector/Fixture/skip_docblock_final_constant.php.inc b/rules-tests/CodeQuality/Rector/ClassConstFetch/VariableConstFetchToClassConstFetchRector/Fixture/skip_docblock_final_constant.php.inc new file mode 100644 index 00000000000..023beaf0446 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/ClassConstFetch/VariableConstFetchToClassConstFetchRector/Fixture/skip_docblock_final_constant.php.inc @@ -0,0 +1,15 @@ +getConstant($constantName); - if (! $constant->isFinal()) { + if (! $constant->isFinalByKeyword()) { return null; } } diff --git a/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php b/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php index 303d6a348ae..7690d6f8db6 100644 --- a/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php +++ b/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php @@ -16,11 +16,8 @@ use PHPStan\Reflection\ClassReflection; use Rector\Configuration\Parameter\FeatureFlags; use Rector\Enum\ObjectReference; -use Rector\Php\PhpVersionProvider; use Rector\PHPStan\ScopeFetcher; use Rector\Rector\AbstractRector; -use Rector\ValueObject\PhpVersionFeature; -use ReflectionClassConstant; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -34,11 +31,6 @@ */ final class ConvertStaticToSelfRector extends AbstractRector { - public function __construct( - private readonly PhpVersionProvider $phpVersionProvider - ) { - } - public function getRuleDefinition(): RuleDefinition { return new RuleDefinition('Change `static::*` to `self::*` on final class or private static members', [ @@ -171,25 +163,8 @@ private function shouldSkip( } if (! $isFinal) { - // init - $memberIsFinal = false; if ($reflection instanceof ClassConstantReflection) { - // Get the native ReflectionClassConstant - $declaringClass = $reflection->getDeclaringClass(); - $nativeReflectionClass = $declaringClass->getNativeReflection(); - $constantName = $reflection->getName(); - - 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(); - } + $memberIsFinal = $reflection->isFinalByKeyword(); } else { $memberIsFinal = $reflection->isFinalByKeyword() ->yes();