|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33698 Conflicts with multiple interfaces sharing common method names
Submitted: 2005-07-14 17:35 UTC Modified: 2015-08-09 21:54 UTC
Avg. Score:4.6 ± 0.6
Reproduced:21 of 23 (91.3%)
Same Version:6 (28.6%)
Same OS:13 (61.9%)
From: jason at hybd dot net Assigned: requinix (profile)
Status: Closed Package: *General Issues
PHP Version: 5.0.4 OS: *
Private report: No CVE-ID: None
 [2005-07-14 17:35 UTC] jason at hybd dot net
This is debateable if this is a bug or not. Personally, I don't regard it as a bug.

Classes that implement >1 interface that share common methods raise fatal errors. Because of the abstract nature of interfaces, no error or warning should be rasied.

I know PHP <> Java, but Java doesn't raise any errors, and PHP5's OO model is very close to Java's

Reproduce code:
    interface FirstInterface
        function execute();
    interface SecondInterface
        function execute();
    class MyClass implements FirstInterface, SecondInterface
        function execute()
            echo "Hello World";
    $obj = new MyClass();

Expected result:
Hello World

Actual result:
Can't inherit abstract function SecondInterface::execute()


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-15 12:44 UTC]
PHP != Java
 [2005-07-15 13:57 UTC] jason at hybd dot net
I know PHP != Java, but surely this sort of stuff should be documented? Most people will expect interfaces to work like Java interfaces or C++ "interfaces" (Pure virtual abstract methods), as many other languages seem to follow this behaviour. As I said this is debatable as it depends how you look at things, and likewise it is fairly easy to work round this issue.
 [2005-07-15 14:13 UTC]
FWIW, I agree; I think our interface support is pretty crappy because of this.

I'm changing this to suspended status, because maybe one day it will appear, it's just not possible at the moment.

 [2007-02-01 09:48 UTC] mail at rones dot de
Is there someone thinking (or even working) on this issue? It is really important if you want to use different 3rd party components which provides interfaces you have to implement to use the components and there exists some methods _with the same signature_ more than once. In case of different signatures I can understand there would occur problems because PHP does not have an method overloading possibility yet.
 [2009-01-28 13:54 UTC] lukasz dot wojciechowski at ngsoft dot pl
I just run into this problem and I decided to post a comment to bring attention to this issue.

Best regards
?ukasz Wojciechowski
 [2011-11-10 12:09 UTC] arkadiusz dot robinski at allegro dot pl
I also encountered this problem. I agree with mail at rones dot de. It is very annoying if you want to implement interfaces from different 3rd party components. Current behaviour should be changed.
 [2015-08-09 13:46 UTC] php at mcq8 dot be
Is fixed in 5.3.9 (
 [2015-08-09 21:54 UTC]
-Status: Suspended +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: requinix
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun May 09 01:01:24 2021 UTC