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 b455c3e
Browse filesBrowse the repository at this point in the historyBrowse files
Resolve "supported only on PHP X" checks from Scope::getPhpVersion() instead of the injected PhpVersion
- Add 20 range-aware `supports*(): TrinaryLogic` methods to `PHPStan\Php\PhpVersions` mirroring their `PhpVersion` counterparts, so scope-narrowed PHP version ranges can answer feature-support queries.
- Switch every rule that emits a non-ignorable "… is supported only on PHP X and later." error to `$scope->getPhpVersion()->supportsX()->yes()`, and drop the now-unused `PhpVersion` constructor dependency:
- `Constants/NativeTypedClassConstantRule` (the reported case), `Constants/FinalConstantRule`, `Constants/DynamicClassConstantFetchRule`, `Constants/ConstantAttributesRule`
- `Classes/ReadOnlyClassRule` (both readonly and anonymous readonly classes), `Classes/ClassConstantRule` (`::class` on an expression), `Classes/InvalidPromotedPropertiesRule` (promoted and final promoted properties)
- `Properties/ReadOnlyPropertyRule`, `Properties/PropertiesInInterfaceRule`, `Properties/PropertyInClassRule` (final properties, property hooks, asymmetric visibility on static properties), `Properties/PropertyAttributesRule`
- `Methods/MethodCallableRule`, `Methods/StaticMethodCallableRule`, `Functions/FunctionCallableRule` (first-class callables)
- `Cast/VoidCastRule`, `Exceptions/ThrowExpressionRule`, `Traits/TraitAttributesRule`, `Functions/ExistingClassesInArrowFunctionTypehintsRule` (never return type)
- `FunctionDefinitionCheck` native union types, covering the four `ExistingClassesIn*TypehintsRule` rules and property hooks
- Add `tests/PHPStan/Rules/php-version-*.neon` fixtures and rework the affected rule tests to configure the analysed PHP version through the container instead of handing a fake `PhpVersion` to the rule, so the scope agrees with the configured version.
- Add 17 regression fixtures declaring the same construct inside `if (PHP_VERSION_ID >= X)`, inside `if (PHP_VERSION_ID < X)` and unguarded; only the latter two are expected to be reported.
- `FunctionCallParametersCheck` (named arguments), `NoncapturingCatchRule` and `FinalPrivateMethodRule` already used the scope and needed no change.
Closesphpstan/phpstan#13133
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments