ID: 43499
Updated by: [EMAIL PROTECTED]
Reported By: bholbrook at servillian dot com
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: Linux Cent OS
PHP Version: 5.2.5
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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