Skip to content

Commit dc4f0b7

Browse files
committed
Bump to PHPStan ^2.1.40 and utilize ClassConstantReflection->isFinalByKeyword()
1 parent 23397d8 commit dc4f0b7

File tree

4 files changed

+4
-23
lines changed

4 files changed

+4
-23
lines changed

build/target-repository/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"require": {
1111
"php": "^7.4|^8.0",
12-
"phpstan/phpstan": "^2.1.38"
12+
"phpstan/phpstan": "^2.1.40"
1313
},
1414
"autoload": {
1515
"files": [

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"nikic/php-parser": "^5.7",
2424
"ondram/ci-detector": "^4.2",
2525
"phpstan/phpdoc-parser": "^2.3",
26-
"phpstan/phpstan": "^2.1.38",
26+
"phpstan/phpstan": "^2.1.40",
2727
"react/event-loop": "^1.6",
2828
"react/promise": "^3.3",
2929
"react/socket": "^1.17",

rules/CodeQuality/Rector/ClassConstFetch/VariableConstFetchToClassConstFetchRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function refactor(Node $node): ?ClassConstFetch
109109
}
110110

111111
$constant = $classReflection->getConstant($constantName);
112-
if (! $constant->isFinal()) {
112+
if (! $constant->isFinalByKeyword()) {
113113
return null;
114114
}
115115
}

rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Rector\Php\PhpVersionProvider;
2020
use Rector\PHPStan\ScopeFetcher;
2121
use Rector\Rector\AbstractRector;
22-
use Rector\ValueObject\PhpVersionFeature;
23-
use ReflectionClassConstant;
2422
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
2523
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
2624

@@ -171,25 +169,8 @@ private function shouldSkip(
171169
}
172170

173171
if (! $isFinal) {
174-
// init
175-
$memberIsFinal = false;
176172
if ($reflection instanceof ClassConstantReflection) {
177-
// Get the native ReflectionClassConstant
178-
$declaringClass = $reflection->getDeclaringClass();
179-
$nativeReflectionClass = $declaringClass->getNativeReflection();
180-
$constantName = $reflection->getName();
181-
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-
) {
189-
// PHP 8.1+
190-
$nativeReflection = $nativeReflectionClass->getReflectionConstant($constantName);
191-
$memberIsFinal = $nativeReflection instanceof ReflectionClassConstant && $nativeReflection->isFinal();
192-
}
173+
$memberIsFinal = $reflection->isFinalByKeyword();
193174
} else {
194175
$memberIsFinal = $reflection->isFinalByKeyword()
195176
->yes();

0 commit comments

Comments
 (0)