php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43200 Interface implementation / inheritence not possible in abstract classes
Submitted: 2007-11-05 15:50 UTC Modified: 2011-11-19 13:35 UTC
Votes:4
Avg. Score:4.5 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: smith at pooteeweet dot org Assigned: felipe (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-11-05 (CVS) OS: Linux
Private report: No CVE-ID: None
 [2007-11-05 15:50 UTC] 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 ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-05 16:34 UTC] 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.
 [2010-12-16 00:38 UTC] 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.
 [2011-10-01 07:55 UTC] lsmith@php.net
-: daniel.gorski@develnet.org +: smith at pooteeweet dot org -Summary: Interface implementation / inheritence not possible in abstract classes +Summary: smith@pooteeweet.org -Status: Bogus +Status: Open -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
 [2011-10-01 07:55 UTC] lsmith@php.net
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).
 [2011-10-02 21:16 UTC] aharvey@php.net
-Summary: smith@pooteeweet.org +Summary: Interface implementation / inheritence not possible in abstract classes -Status: Assigned +Status: Open -Operating System: smith@pooteeweet.org +Operating System: Linux -PHP Version: smith@pooteeweet.org +PHP Version: 5.3CVS-2007-11-05 (CVS) -Assigned To: smith@pooteeweet.org +Assigned To:
 [2011-10-02 21:16 UTC] aharvey@php.net
Revert the various field changes that crept in. I'll let one of the engine 
developers figure out if this should be left open or re-bogused.
 [2011-11-18 23:26 UTC] lsmith@php.net
I should also clarify that the issue also exist when simply dealing with 
interfaces only aka when an interface extends another interface. I am aware that 
we do not support polymorphism, but again when dealing with legacy interfaces 
there will be overlaps with signatures that are identical.
 [2011-11-19 13:35 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2011-11-19 13:35 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2011-11-19 13:35 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=319548
Log: - Fixed bug #43200 (Interface implementation / inheritence not possible in abstract classes)
 [2012-04-18 09:47 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=14b5e775b01ab22d9686a7ab2ce7b805f5818233
Log: - Fixed bug #43200 (Interface implementation / inheritence not possible in abstract classes)
 [2012-07-24 23:38 UTC] rasmus@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=14b5e775b01ab22d9686a7ab2ce7b805f5818233
Log: - Fixed bug #43200 (Interface implementation / inheritence not possible in abstract classes)
 [2013-11-17 09:35 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=14b5e775b01ab22d9686a7ab2ce7b805f5818233
Log: - Fixed bug #43200 (Interface implementation / inheritence not possible in abstract classes)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC