-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can be removed the need for private methods start with underscore? #3
Comments
+1 |
Hi, The public methods of any class is external API of library. The leading underscore helps us to control that API in any place of code without documentations or IDE. If some method become public we can rename it with IDE refactoring feature for a few seconds. Developers in my company decided that we will use PSR Code Style with some minor fixes and check it via phpmd & phpcs with other tests. All ruleset saved to JBZoo/Misc package and you can add it to phpstorm easily. Why do you think that undersoce is bad ? Do you have some bad practice with it ? Thanks and best regards, Denis. |
Hi, Yes, PSR-2 disallow it:
Personally I don't think is useful, and according to this thread, this practice appeared because of poor implementation of OOP in PHP4, that didn't support visibility. |
Yes, I know. Very quick understanding what kind of method I'm using in class (public or not) is more important that PSR. Because external API of any class is very important stuff and developer should monitor that always. Nobody cares how class works - everybody use public methods of libs. Underscore is easy method to do it without any docs or IDE. I can just look a code! PSR standards are just some recommendations which based on statistics. And it doesn't explain "why". Anyway you can rename all methods in your fork and use it ;) PS. PHP 4 died more then 10 years ago, so I never use it and don't know how it worked. |
Sorry, don't think this practice is useful. You should look at the method to see what he is doing. Then you see their visibility. Maybe I'll fork it. :) Anyway, you can close this issue if you like. |
Hi there,
Don't think that starting the function name of private methods with an underscore can be useful. Can this be removed from the ruleset?
Thanks!
The text was updated successfully, but these errors were encountered: