-
Notifications
You must be signed in to change notification settings - Fork 51
Sanity check #[RequiresPhp] value and range
#269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.0.x
Are you sure you want to change the base?
Conversation
| $testPhpVersionConstraint = $parser->parseConstraints($args[0]); | ||
| } catch (UnexpectedValueException $e) { | ||
| $errors[] = RuleErrorBuilder::message( | ||
| sprintf($e->getMessage()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure we want to 1:1 print the message from composer/semver as a phpstan rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternative approach could be to somehow analyse #[RequiresPhp('>=8.0')] as if it would have the AST of PHP_VERSION_ID >= 80000 - which would re-use the already existing PHP_VERSION_ID checking capabilities
| $this->deprecationRulesInstalled = $deprecationRulesInstalled; | ||
|
|
||
| $parser = new VersionParser(); | ||
| $this->phpstanVersionConstraint = $parser->parseConstraints($phpVersion->getVersionString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this should compare against the composer.json min version instead of the phpstan.neon version?
|
I'd rather use https://github.com/phar-io/version which is also used by PHPUnit I think https://github.com/sebastianbergmann/phpunit/blob/2d6dc600b52cd74141c422a5d0601ca26c185bb9/src/Metadata/Version/Requirement.php Yeah, comparing against |
thats only one part of the story. see also https://github.com/sebastianbergmann/phpunit/blob/2d6dc600b52cd74141c422a5d0601ca26c185bb9/src/Metadata/Version/Requirement.php#L41-L48 which adds a fallback path on top which is implemented in phpunit itself. reworked it to match that |
#[RequiresPhp]is lower then the phpstan analysis version, reports a test requirement as beeing always false#[RequiresPhp]contains a version which is not parse-able, reports a error