Remove PHP version constraint from the `#[\Override]` attribute rules
There are two PHPStan rules relating to use of the #[\Override] attribute on methods:
method.missingOverridewhich detects when a method overrides another but is missing the#[\Override]attribute. This rule is operational only when thecheckMissingOverrideMethodAttributeconfig option is set to true.method.overridewhich detects when#[\Override]is used on a method which does not override a method.
Currently these rules are triggered when PHP 8.3 or higher is in use, because that's the version that introduced support for this attribute.
However both of these rules are opt-in and therefore don't need to be constrained by PHP version. The former is explicitly opt-in via the checkMissingOverrideMethodAttribute config option and the latter is implicitly opt-in via the existence of an #[\Override] attribute on a method.
This PR proposes removing the PHP version constraint from these rules so they can be applied to a codebase which supports versions of PHP older than 8.3 and still benefit from static analysis by PHPStan.
What's the use case?
I work on codebases which support PHP 7.4 to 8.4. I want to make use of the #[\Override] attribute on methods and have PHPStan confirm that their usage is correct. The fact that the codebase is compatible with PHP < 8.3 should be of no relevance to these rules.
Currently if the following PHP version range config is in phpstan.neon then the #[\Override] attribute rules don't apply and PHPStan won't check their correctness.
phpVersion:
min: 70400
max: 80400
Is this a breaking change?
I don't believe this should be considered a breaking change, however there may be codebases that are using #[\Override] attributes and a supported version of PHP lower than 8.3 that don't realise these rules are not currently being applied. These rule changes may cause previously passing incorrect use of #[\Override] to now fail, which arguably is a bugfix.
This pull request has been marked as ready for review.