rectorphp / rector-phpunit

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

AnnotationWithValueToAttributeRector not applied due to DoctrineAnnotationTagValueNode #297

Open mfn opened 7 months ago

mfn commented 7 months ago

Hi,

I noticed some @group … directives not being adapted and after a bit debugging I notice that in \Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector::refactor the call to getTagsByName returned DoctrineAnnotationTagValueNode instead of GenericTagValueNode.

But there is this check which makes it not pass:

if (!$desiredTagValueNode->value instanceof GenericTagValueNode) {
    continue;
}

As to why: well, I've a (namespaces) class \Project\Models\Group imported in some tests and I guess rector treats the class Group special with @group. However, in my case there's no relation here and since the default config in annotations-to-attributes.php uses the FQCN anyway, there's no clash.

What can I do to still have such @group being converted?

I'm talking about using this in CI, so I'm not looking for a one-time transformation here.

Thanks

TomasVotruba commented 3 weeks ago

Hi, thanks for patience on this one. I'll make it a priority to pass.

Could you share a broken test fixture using demo? https://getrector.com/demo