On Fri, May 27, 2011 at 12:52 PM, Daevid Vincent <dae...@daevid.com> wrote:

> A friend sent me this URL today. While amusing, he's got many valid points
> and I certainly share in his frustration.
> http://www.phpsadness.com

Some points are valid, but many others show a lack of understanding of PHP
and OOP in general.

* #18 (as stated) is intentional. If you want an instance property--use an
instance property! A static variable in an instance method could do one of
two things: create a static variable private to the method or an instance
variable private to the method. But using "static" to create an instance
property would be very confusing.

* #24 on reflection methods. I agree that the lack of documentation is sad,
but allowsNull() and isOptional() are definitely separate. Any parameter
with a type hint (array or class) will allow null only if it has a null
default value. So a parameter can be optional and disallow null and vice

* #33 The point of private methods is to block subclasses (and other
classes) from accessing or overriding them. Yes, it makes mocking them
impossible, but this is a core OOP concept. Make those methods protected and
put a comment on them stating that they should not be overridden by
subclasses if you need to mock them.

* #41 You can create a final class with a private constructor or better yet
simply *avoid* instantiating the class. Problem solved. Seriously, who cares
if someone instantiates your class full of static methods?

Hopefully we're all a little less sad now. :)


Reply via email to