I want to use the ClassPropertyAssignToConstructorPromotionRector rector but not when the class uses a Doctrine #[Entity] attribute.
There is no easy way to do this, other than to submit a PR to make this a configuration option, but this feels something that is just our preference.
I see 2 solutions to solve this:
-
Create a SkipEntityRector delegates the work to ClassPropertyAssignToConstructorPromotionRector only when the class does not implement the #[Entity] attribute. But the issue is, in rector.php you can only specify Rector rules as class-string and not as instances. Can we maybe allow that?
-
Allow passing a callable to withSkip that could be used to hook into the Node, Scope, and then ignore when the attribute is there.
/cc @samsonasik