Re: LSB forward_static_call()
| From: | Ryan Panning | Date: | Tue, 24 Jun 2008 19:56:58 +0000 |
| Subject: | Re: LSB forward_static_call() | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals php.internals |
| Request: | Send a blank email to internals+get-38600@lists.php.net to get a copy of this message | ||
Janusz Lewandowski wrote:
<?php class A { function mA() { $this->nA(); } static function mB() { self::nB(); } } class B extends A { function mA() { parent::mA(); } static function mB() { parent::mB(); } function nA() { echo 'A'; } function nB() { echo 'B'; } } $obj = new B(); $obj->mA(); B::mB(); ?> Most people will think, that it will output AB. But currently in PHP 5.2 (I don't have PHP 5.3 to test it) it will output: A Fatal error: Call to undefined method A::nb() in Z:\localhost\testLSB.php on line 11 User that sees this, doesn't have any idea where is the problem and how to find some information about it.If I may throw my 2 cents in, if it's even worth anything anyway. This is exactly what I would expect the output to be. If you would want A::mB() to go back to B::nB() I would switch the self::nB() to static::nB(), and have an abstract nB() method declared in A. Is this not how everyone thinks it should be?