-
-
Notifications
You must be signed in to change notification settings - Fork 735
Closed
rectorphp/rector-phpunit
#492Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.0.8 |
in my test-suite rector is creating the following diff:
namespace rocket\tests\unit\lib;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
final class RegexFormatsUrlTest extends TestCase
{
- /**
- * @dataProvider provideValidUrls
- *
- * @uses \RegexFormats
- */
+ #[DataProvider('provideValidUrls')]
+ #[UsesClass('\RegexFormats')]
public function testUrlRegexValid(string $url): void
{
self::assertTrue((bool) preg_match('{' . REGEX_URL . '}', $url));
}
----------- end diff -----------
Applied rules:
* DataProviderAnnotationToAttributeRector
* PreferPHPUnitSelfCallRector
* PreferPHPUnitThisCallRector
* AnnotationToAttributeRector
* AddParamTypeBasedOnPHPUnitDataProviderRector
the problem here is, that a #UsesClass attribute is created at method level, but it is only valid at class level, see
Minimal PHP Code Causing Issue
unfortunately I am not able to reproduce it in the sandbox
https://getrector.com/demo/771e7c3e-d548-4aae-8b12-c9593e40d507
Expected Behaviour
#UsesClass - similar to e.g. #CoversMethod should move the annotation to class-level even if the phpdoc itself was at method level