How to refactor a method based on some other parts of the file #7822
-
|
Hi there, First of all, thanks for the awesome work done on Rector. I've been looking for examples of refactoring that needs some kind of memory/persistence but I failed to find something relevant (probably because I don't really know how to state my problem...). Here it is, I've got some classes that looks like: class Stuff {
...
public function getHooksAndCallbacks() {
$this->addHook('some_event1', 'someString1');
$this->addHook('some_event2', 'someString2');
}
...
public function someString1(...) {}
public function someString2(...) {}
}I want to inject Attributes on Ideal result would be class Stuff {
...
#[SomeAttribute('some_event1')]
public function someString1(...) {}
#[SomeAttribute('some_event2')]
public function someString2(...) {}
}I would need some kind of double processing of the file I guess but there is maybe a better approach. Any suggestion ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi, you can process it just once. Hook into the |
Beta Was this translation helpful? Give feedback.
Hi, you can process it just once. Hook into the
Class_node and handle it there.