4 ms·
To be honest, for a 23 year old language, that isn't a large list. With python 2vs3 I could write a book. One issue: "The point of private methods is to prev
by ransom1538 8y ago
To be honest, for a 23 year old language, that isn't a large list. With python 2vs3 I could write a book.
One issue:
"The point of private methods is to prevent what other code can call them. However, in PHP, you also cannot override private methods in a subclass. This is especially important when, for example, trying to build mocks in unit tests."
That is called "protected". With protected you can override the method. "private" means it is private to that class overriding - I believe this was concept was extracted from C++.
"In general, you don't want to break any encapsulation for the sake of testing (or as Mom used to say, "don't expose your privates!"). Most of the time, you should be able to test a class by exercising its public methods. If there is significant functionality that is hidden behind private or protected access, that might be a warning sign that there's another class in there struggling to get out."