rector: `MethodCallToPropertyFetchRector` cannot be restricted to dedicated class
Question
I use PropertyFetchToMethodCallRector like this:
$services->set(PropertyFetchToMethodCallRector::class)
->configure([
new PropertyFetchToMethodCall(Generator::class, 'boolean', 'boolean'),
]);
Change ->boolean to ->boolean() on class Generator::class. It works like a charm.
However, after upgrading to PHP 8.1 (using rector), I have a lot of private readonly string $foo. And I don’t need the getFoo() method anymore.
My plan was to use MethodCallToPropertyFetchRector (the opposite), but I realized, that based on the docs (https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#methodcalltopropertyfetchrector), I am not able to restrict this method call to a certain class.
Thanks for your help.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (21 by maintainers)
@OskarStark I see. It’s rather forgotten use import 😃 Btw, if you can share new comment with link it would be easier to follow. Updating past comment can be pretty confusing.
@OskarStark could you create failing test case? Thank you.
I’m not sure what do you mean. Demo example with configure rule would be better. Thank you 👍