From: Operating system: Windows XP Pro w/IIS PHP version: 5.3.2 Package: Class/Object related Bug Type: Bug Bug description:Incorrect Inheritence Order Within The Context Of The Class
Description: ------------ If you have a child class that overrides a parent class method, and call that method within the context of the parent, the parent's method is called first, then the child class. This always happens. If you call the method outside of the class, then the child's method is called, and the parent's method is only ran if you tell it to using parent:: If you add a third level of inheritance, under the same conditions, the parent class will still call first, but the lowest child is called, skipping those in between. Adding: ... class bar2 extends bar { public function foo() { echo 'in_child_2:'; } } $objClass = new bar(); ... Results in in_parent:in_child_2: Test script: --------------- <?php class foo { public function foo() { echo 'in_parent:'; } public function bar() { $this->foo(); } } class bar extends foo { public function foo() { echo 'in_child:'; } } $objClass = new bar(); $objClass->bar(); $objClass->foo(); ?> Expected result: ---------------- in_child:in_child: Actual result: -------------- in_parent:in_child:in_child: -- Edit bug report at http://bugs.php.net/bug.php?id=51504&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51504&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51504&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51504&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51504&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51504&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51504&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51504&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51504&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51504&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51504&r=support Expected behavior: http://bugs.php.net/fix.php?id=51504&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51504&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51504&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51504&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51504&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51504&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51504&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51504&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51504&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51504&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51504&r=mysqlcfg