How to add a custom rule to add return types - only for specific classes/methods

68 Views Asked by At

i'm fairly new to rector and only know its basic usage.

I want to add return types for only a few methods, so i cant use the built-in rules. (?)

I've an interface with ...

public funtion getSomeText();

... that changed to ...

public funtion getSomeText(): string;

Now a want to fix only methods, that implement that interface. Classes that dont implement it should not be touched.

Ive checked through exising rules, code examples ... but dit not find what im looking for.


Same question for https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#addpropertytypedeclarationrector

How to limit it to specific properties? (i cant run reactor for the whole project, i need to do it step by step)

0

There are 0 best solutions below