Bug #43200 [Bgs->Opn]: smith@pooteeweet.org
| From: | lsmith@php.net | Date: | Sat, 01 Oct 2011 07:55:34 +0000 |
| Subject: | Bug #43200 [Bgs->Opn]: smith@pooteeweet.org | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-164015@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=43200&edit=1
ID: 43200
Updated by: lsmith@php.net
Reported by: smith at pooteeweet dot org
-Summary: Interface implementation / inheritence not possible
in abstract classes
+Summary: smith@pooteeweet.org
-Status: Bogus
+Status: Open
Type: Bug
Package: Scripting Engine problem
-Operating System: Linux
+Operating System: smith@pooteeweet.org
-PHP Version: 5.3CVS-2007-11-05 (CVS)
+PHP Version: smith@pooteeweet.org
-Assigned To:
+Assigned To: smith@pooteeweet.org
Block user comment: N
Private report: N
New Comment:
This is not bogus and it should be fixed. In many cases I in the end managed to
work around this, but its not always possible, like when dealing with legacy
interfaces that one cannot change etc, but that are being superseded by newer
ones (f.e. https://github.com/symfony/symfony/pull/2244).
Previous Comments:
------------------------------------------------------------------------
[2010-12-16 00:38:40] kucho86 at gmail dot com
Are you planning to cover this bug??
It's pretty simple to fix and since interfaces define behaviours and classes implements them,
this should be possible.
It goes against Object Oriented Programming concepts.
------------------------------------------------------------------------
[2007-11-05 16:34:21] cellog@php.net
<?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.
------------------------------------------------------------------------
[2007-11-05 15:50:30] smith at pooteeweet 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 https://bugs.php.net/bug.php?id=43200&edit=1