fix: PhpUnitAttributesFixer - convert correctly version constraint#8439
Conversation
| return self::createAttributeTokens($tokens, $index, $attributeName, ...$attributeTokens); | ||
| } | ||
|
|
||
| private static function fixVersionConstraint(string $version): string |
There was a problem hiding this comment.
@sebastianbergmann is this how version constraint from annotation should be converted for attributes? The argument here is what is in annotation (e.g. @requires PHP 8.2) and the returned value is what will be in the attribute (e.g. #[RequiresPhp('>= 8.2')].
There was a problem hiding this comment.
overall yes, if there is no operator, it is defaulted to >=
ref https://github.com/sebastianbergmann/phpunit/blob/8.5.12/src/Util/Test.php#L161
|
|
||
| private static function fixVersionConstraint(string $version): string | ||
| { | ||
| if (Preg::match('/^[\d\.]+$/', $version)) { |
There was a problem hiding this comment.
we shall cover non-stable releases too, like PHPUnit does, eg 5.4.0-alpha1
ref https://github.com/sebastianbergmann/phpunit/blob/8.5.12/src/Util/Annotation/DocBlock.php#L33
keradus
left a comment
There was a problem hiding this comment.
overall almost 👍🏻 , thanks for working on it.
i found one failing case
To test different/more cases:
composer update-> PHPUnit 11 will be installed which supports both - annotations and attributes.generate.php:CASESto what you want verify.log1.log(annotations) withlog2.log(attributes) to see if the same tests were skipped.