Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Dec 5, 2025

  • when #[RequiresPhp] is lower then the phpstan analysis version, reports a test requirement as beeing always false
  • when #[RequiresPhp] contains a version which is not parse-able, reports a error

$testPhpVersionConstraint = $parser->parseConstraints($args[0]);
} catch (UnexpectedValueException $e) {
$errors[] = RuleErrorBuilder::message(
sprintf($e->getMessage()),
Copy link
Contributor Author

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

Copy link
Contributor Author

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());
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant