Archive for the ‘php’ Category


Whats Wrong with Object Orientation in PHP.

July 1, 2014

PHP copies the basic Implementation of OO from C++, a static language, and then , seemingly noticing that it is unnecessarily restrictive, allows escape means of magic methods.


At Last, a Use for Late Static Bindings!

June 18, 2014

I had a base class called Bee. From that I was deriving Queen Bee, Worker Bee, etc. The only difference between the derived classes where certain constants are used to initialise certain data members. That being the case, it would be useful if the constructor on the base class did all the work. The class constants on the dreived classes need to be passed back to the constructor on the base class. Since constructor in PHP have to chain up the hierarchy manually, using parent:__construct() , this can be done by passing jn the derived class constants to the parameter list. However, that is almost as repetitive as giving the derived classes their own constructors. Trying to do it it all in the base class constructor using self:: doesn’t work…because self:: isn’t forward…it tries to pull constants from the base class itself,. For the constructor on the base class to pull in constants from the derived class that chained back ti it, you need forward bindings, which means replacing self:: with static:: in the base class constructor.