|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-12-05 10:59 UTC] jani@php.net
[2007-12-05 16:41 UTC] bholbrook at servillian dot com
[2007-12-07 03:08 UTC] crrodriguez at suse dot de
[2007-12-07 11:00 UTC] jani@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 07:00:01 2025 UTC |
Description: ------------ In the example, class A gains a knowledge of it's extending classes functions. By allowing the call from the entended class to an extending class method, the extended class method becomes unavailable to any other extending class. The only time this makes sense is if class A were an abstract class and defined method3 as an abstract function. Reproduce code: --------------- <?php class A { public function method1(){ echo "I am method A::method1<br/>"; $this->method3(); } } class B extends A{ public function method2(){ echo "I am method B::method2<br/>"; $this->method1(); } public function method3(){ echo "I am method B::method3<br/>"; } } class C extends A{ public function method4(){ echo "I am method C::method4<br/>"; $this->method1(); } } $oB = new B(); $oB->method2(); $oC = new C(); $oC->method4(); ?> Expected result: ---------------- The expected result of $oB->method2(); is the current results of $oC->method4(); Actual result: -------------- Currently, $oB->method2() calls A::method1() (correct) which in turn calls B::method3() (incorrect).