rectorphp / rector-phpunit

Rector upgrade rules for PHPUnit
http://getrector.com
MIT License
61 stars 46 forks source link

Activate dataproviders with php8 attributes for phpunit 10+ #272

Closed eerison closed 8 months ago

eerison commented 9 months ago

Hello

is there anyway to apply rules by phpunit version or just php version?

As I can see in the doc this #[DataProvider] attribute is available in phpunit 10 only

https://github.com/rectorphp/rector-phpunit/blob/main/rules/AnnotationsToAttributes/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php

9.x - https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#data-providers 10.x - https://docs.phpunit.de/en/10.4/writing-tests-for-phpunit.html#data-providers

eerison commented 8 months ago

Should be good if we could apply rules depending of phpunit version, because I faced other issue regarding it

for example this rule https://github.com/rectorphp/rector-phpunit/blob/main/docs/rector_rules_overview.md#withconsecutiverector is used in phpunit10 list, But I'm using phpuni9.

But in other hand there are rules in phpuni10 that I want to use in phpunit9 that remove some deprecations.

then at the moment I just see the solution to skip this rule :/, But if I do this I need to make this for others rules as well, like the dataproviders

TomasVotruba commented 8 months ago

For php version there is min php version interface.

eerison commented 8 months ago

For rules that just work for phpunit10 , does make sense we strick the minimum php version 8.1?

TomasVotruba commented 8 months ago

Sounds good :+1:

I wonder how it can happen people use PHPUnit 10 on PHP 8.0 though.