Archive for the ‘General’ Category

PHP is a very popular dynamic language that empowers hundreds of web sites, this blog included, but at current time it has an object-oriented implementation that lacks some stuff I would love to have.

For example today i tried this method definition that uses type hinting as I wanted only class instances as values for the $target parameter:

[code='PHP']
public function myMethod(object $target) {
... My Method logic ...
}
[/code]

But when you execute the method PHP complains at every defined class you pass, and that’s because in PHP each defined class doesn’t inherit automatically for object, so if you wanted that, you are in trouble and the only thing you can do is add a check in the method body:

[code='PHP']
public function myMethod($target) {
if (!is_object($target)) {
throw new Exception("Parameter $target must be a class instance");
}

... My Method logic ...
}
[/code]

But that requires wasting 3 lines of code and the time to type them with something the language could do itself and almost do, as you can put there your own class or interface and pass instances that inherit or implement them.

Hopefully there is more people interested in PHP getting improvements in it’s OO implementation and there is almost a working patch somewhere to add support for what I wanted to do and more. Maybe it can make it way into the long expected PHP 6.

I’ve just made that question to myself and found something that maybe answers it: Drupal Vs Joomla, frank comparison from an IBM consultant.

Amazing, if it were true: Amazon Quantum Cloud Computing