phpstan-phpunit icon indicating copy to clipboard operation
phpstan-phpunit copied to clipboard

Sanity check `#[RequiresPhp]` value and range

Open staabm opened this issue 2 weeks ago • 2 comments

  • 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

staabm avatar Dec 05 '25 14:12 staabm

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 PHP_VERSION_ID would take care of all issues. We just need to properly understand the constraints in all cases.

ondrejmirtes avatar Dec 08 '25 08:12 ondrejmirtes

I'd rather use phar-io/version which is also used by PHPUnit I think sebastianbergmann/phpunit@2d6dc60/src/Metadata/Version/Requirement.php

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

staabm avatar Dec 08 '25 09:12 staabm