laravel-shift / blueprint

A code generation tool for Laravel developers.
MIT License
2.82k stars 270 forks source link

Change generator methods visibility from "private" to "protected" #658

Closed mowses closed 6 months ago

mowses commented 9 months ago

Synopsis:

I would like to customize the Blueprint generators a bit (for example /src/Generators/ModelGenerator.php, so instead of copying the original class and modify it, I would like to just extend from the original class and override the methods I need. This way I keep my implementation slim and still can get the updates from the original file.

The problem I faced was with the private methods, which I could not override. I tried to find a protected parent method to override and create my own implementation, but in the end I came up with almost the entire class replicated, just to customize a single method.

I would like to suggest to change from private methods to protected, since it can be extended when needed.

Proposed Syntax:

Change private methods to protected.

Expected Behavior:

It wont break anything and still can be extended and customized from the main application.

jasonmccreary commented 9 months ago

Feel free to open a PR with the methods you need protected. I ask that you do it consistently to all generators.

jasonmccreary commented 6 months ago

I have reviewed all of the Generators and opened up any method I felt might make sense to override. What's left is internal or dictated by Laravel convention. If someone needs access to that method, they can override the calling method.