ID: 43499 Comment by: crrodriguez at suse dot de Reported By: bholbrook at servillian dot com Status: Open Bug Type: Scripting Engine problem Operating System: Linux Cent OS PHP Version: 5.2.5 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php http://php.net/manual/en/language.oop5.visibility.php "Public declared items can be accessed **everywhere**".. and you have an instance of C class that extends A , so it is the expected behaviuor.. Previous Comments: ------------------------------------------------------------------------ [2007-12-05 16:41:53] bholbrook at servillian dot com $oB->method2() should work, but the call $this->method3() from A::method1() should cause the same fatal error seen when calling it through $oC->method4(); Class A should have no knowledge of it's extending classes methods. ------------------------------------------------------------------------ [2007-12-05 10:59:36] [EMAIL PROTECTED] Output: I am method B::method2 I am method A::method1 I am method B::method3 I am method C::method4 I am method A::method1 Fatal error: Call to undefined method C::method3() in /home/jani/t.php on line 6 Exactly what is wrong in this? AFAICT, it works exactly how it's supposed to work. ------------------------------------------------------------------------ [2007-12-04 22:36:54] bholbrook at servillian dot com 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). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43499&edit=1