PHP: self:: vs. static::

I am seeing more and more PHP code with static:: key used for method calls instead of self::.  Today I’ve finally found some time to examine the novelty.  The page that is useful for more details is PHP’s late static binding.  This functionality is available since PHP 5.3.0 so you might as well start using it.

I am a bit protective of my code, so self:: feels like a safer, more natural option.  But after thinking about it for a bit, and discussing with my colleagues, I came to the conclusion that I should be using static:: instead of self::.  It provides cleaner inheritance and minimizes code copy-pasting.

 

Ten Things I Hate About Object-Oriented Programming

Ten Things I Hate About Object-Oriented Programming

Apparently I’m not the only one. In the immortal words of Edsger Dijkstra: “Object-oriented programming is an exceptionally bad idea which could only have originated in California.