You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d7039e3
Browse filesBrowse the repository at this point in the historyBrowse files
Keep the analysed PHP version as the floor of a PHP_VERSION_ID < X guard
When a single PHP version is analysed (a fixed `phpVersion`, or no version
range from the config or composer.json), PHP_VERSION_ID is int<50207, max>
and Scope::getPhpVersion() treats that as no information and answers with
the analysed version. A guard like `if (PHP_VERSION_ID < 80400)` narrows
the constant to int<50207, 80399>, and getPhpVersion() returned that range
as is, so the version dropped to PHP 5.2.7 inside the branch. Since the
"supported only on PHP X" rules read the version from the scope, a class
with promoted properties in such a branch got a non-ignorable
property.promotedNotSupported error with `phpVersion: 80500`.
Only the upper bound of that range comes from the guard. Raise the lower
bound to the analysed version, or to the guard's upper bound when the guard
excludes the analysed version. Guards with a lower bound
(`PHP_VERSION_ID >= 80300`) and configured version ranges are unchanged.
The turbo-ext mirror gets the same change.
Closesphpstan/phpstan#15425
->assignExpression($sfGuardedVersionFetch, \PHPStan\Type\IntegerRangeType::fromInterval(\PHPStan\Analyser\ConstantResolver::PHP_MIN_ANALYZABLE_VERSION_ID, $sfGuardedMax), new \PHPStan\Type\IntegerType()),
657
+
);
658
+
$sfGuardedVersionArgs['phpVersion'] = new \PHPStan\Php\PhpVersion(80500);
659
+
$sfGuardedVersionArgs['configuredPhpVersionRangeHelper'] = new \PHPStan\Php\ConfiguredPhpVersionRangeHelper(80500, $scContainer->getByType(\PHPStan\Php\ComposerPhpVersionFactory::class));
660
+
$sfGuardedVersionScope = new \PHPStan\Analyser\MutatingScope(...array_values($sfGuardedVersionArgs));
->assignExpression(new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('PHP_VERSION_ID')), new \PHPStan\Type\Constant\ConstantIntegerType($sfVersionId), new \PHPStan\Type\IntegerType());
@@ -759,6 +788,9 @@ public function exprRef(Node\Expr $expr): mixed
759
788
// the scopes whose tables are built per side (each side's own Type classes)
0 commit comments