Comments (5)
+1
from utils.
Hi,
The public methods of any class is external API of library.
And it's really really really important to decide what information and actions have external access.
The leading underscore helps us to control that API in any place of code without documentations or IDE.
I think usually you are using publc methods of library and don't care about internal processes.
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.
from utils.
Hi,
Yes, PSR-2 disallow it:
Method names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility.
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.
from utils.
Yes, I know.
I read really a lot of threads and discussions about that before making the decision.
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!
phpmd helps to monitor it strongly.
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.
from utils.
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.
from utils.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from utils.