ID: 31943 User updated by: alberto dot delatorre at gmail dot com Reported By: alberto dot delatorre at gmail dot com -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Windows XP SP2 PHP Version: 5.0.3 New Comment:
So Previous Comments: ------------------------------------------------------------------------ [2005-02-12 00:49:29] alberto dot delatorre at gmail dot com Sorry, the visibility in both _foo definitions must be protected, not private. ------------------------------------------------------------------------ [2005-02-12 00:46:45] alberto dot delatorre at gmail dot com Description: ------------ If you have an abstract method inside an abstract class (obvious) and you call that method inside another non-static method within the class, you get an error. If this is an abstract class, it is suposed that a non-static method defined in the class, may have been called from an instance of a child class of that class (cause this class is abstract), and this child class may not be abstract, to be instantiated. So the abstract method have must been overloaded in the non-abstract child class and the call in the non-static method must be valid. I encountered a waste solution, making a reference to $this in the marked lines, so the error is not be triggered. If we substitute the marked line with: $aux_this=&$this; $aux_this->_foo(); The error doesn't appear. Sorry for my english, if it is embarrasing. Reproduce code: --------------- <?php abstract class A { public function foo() { $this->_foo(); // THIS LINE IS MARKED ;) } private abstract function _foo(); } class B extends A { private function _foo(){ echo "foo!!"; } } $b=new B(); $b->foo(); ?> Expected result: ---------------- foo!! Actual result: -------------- Fatal error: Cannot call abstract method A::_foo() in myphp.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31943&edit=1