rectorphp/rector

refactor massive classes according to single responsibility principle (Separation of Concerns #SOLID)

allanlaal opened this issue · 1 comments

Feature Request

add a refactor that refactors all public methods of massive classes (usually controllers) according to single responsibility principle (Separation of Concerns #SOLID) + all of their usages

i.e:
SpaghettiController.php:
class SpaghettiController ..
{

	public function list() {...}

	public function show()  {...}

    public function delete()  {...}
}

into separate files in the same directory:

SpaghettiListController.php:

class SpaghettiListController .. {
    public function __invoke () {...}
}

SpaghettiShowController.php:

class SpaghettiShowController .. {
    public function __invoke () {...}
}

SpaghettiDeleteController.php:

class SpaghettiDeleteController .. {
    public function __invoke () {...}
}

as you can see, it would be great if it would leave the (configured/detected) conventional suffix (such as *Controller, *Collection, *Resource etc) as is

Hi, this would be great contribution. We are focusing on the core now, to make it faster and more reliable. Thus we don't have time for those. It would also require upgrade of route paths, that are framework specific etc.

Feel free to add such a feature or create a custom Rector set to handle this 👍