PHP 5 scope resolution problem
I was working a lot with PHP 4, with PHP5 I work for not very long time. For now the most disappointing thing in PHP 5 is scope resolution problem. It is described in ian at [first name]henderson dot org comment:
Please note that methods called by the scope resolution operator which are defined by a superclass of the first operand are called in the scope of the SUPERCLASS. For example,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 <?php class ExampleSuperclass { static function classType() { return "superclass"; } static function doSomething() { echo "doing something with " . self::classType(); } } class ExampleClass extends ExampleSuperclass { static function classType() { return "subclass"; } } ExampleClass::doSomething(); // output is "doing something with superclass"! ?>This can be surprising (it surprised me!) when coming from other object-oriented languages, which would output “doing something with subclass” in this case.
The answer was:
The functionality you’ve expected maybe will be possible in PHP6….
That’s pity.