#43200 [Opn->Bgs]: Interface implementation / inheritence not possible in abstract classes
| From: | cellog@php.net | Date: | Mon, 05 Nov 2007 16:34:21 +0000 |
| Subject: | #43200 [Opn->Bgs]: Interface implementation / inheritence not possible in abstract classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119296@lists.php.net to get a copy of this message | ||
ID: 43200
Updated by: cellog@php.net
Reported By: daniel dot gorski at develnet dot org
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5.3CVS-2007-11-05 (CVS)
New Comment:
<?php
interface A {
function foo();
}
abstract class B implements A {
}
class C extends B {
public function foo() {
echo 'works';
}
}
$o = new C();
$o->foo();
?>
If you don't want to implement a method from an interface, don't
redeclare it, and the code will work as intended.
Previous Comments:
------------------------------------------------------------------------
[2007-11-05 15:50:30] daniel dot gorski at develnet dot org
Description:
------------
PHP 5.3.0-dev (cli) (built: Nov 5 2007 16:42:56) from todays CVS
HEAD.
The implementation of interfaces in concrete abstract classes and their
inheritence is not possible:
Reproduce code:
---------------
<?php
interface A {
function foo();
}
abstract class B implements A {
abstract public function foo();
}
class C extends B {
public function foo() {
echo 'works';
}
}
$o = new C();
$o->foo();
?>
Expected result:
----------------
Echoing "works"
Actual result:
--------------
Fatal error: Can't inherit abstract function A::foo() (previously
declared abstract in B) in ...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43200&edit=1