Skip to content

Allow passing AbstractRector instances to withRules or support callable in withSkip #9243

@ruudk

Description

@ruudk

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:

  1. 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?

  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions