php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52730 Impossible to implement Interfaces with same method names
Submitted: 2010-08-29 13:02 UTC Modified: 2010-08-29 17:19 UTC
From: wrzasq at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.3 OS: Debian
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wrzasq at gmail dot com
New email:
PHP Version: OS:

 

 [2010-08-29 13:02 UTC] wrzasq at gmail dot com
Description:
------------
It's impossible to implement interfaces with same method names. Whath's the most strange is, that you can simply "hack" this by implementing each interface at different inheritance level.

(it's in fact PHP 5.3.2 issue, but I didn't see it fixed in PHP 5.3.3)

Test script:
---------------
first case:
--
interface Foo
{
    public function getID();
}

interface Bar
{
    public function getID();
}

class A implements Foo, Bar
{
    public function getID()
    {
        return 1;
    }
}

second case:
--
interface Foo
{
    public function getID();
}

interface Bar
{
    public function getID();
}

class A implements Foo
{
    public function getID()
    {
        return 1;
    }
}

class B implements Bar
{
}

third case:
--
interface Foo
{
    public function getID();
}

interface Bar
{
    public function getID();
}

class A implements Foo
{
    public function getID()
    {
        return 1;
    }
}

class B implements Bar
{
    public function getID()
    {
        return parent::getID();
    }
}

Expected result:
----------------
Nothing at output, but all of them compile.

Actual result:
--------------
first case: Fatal error: Can't inherit abstract function Bar::getID() (previously declared abstract in Foo) in Command line code on line 1
second case: Fatal error: Can't inherit abstract function Bar::getID() (previously declared abstract in Foo) in Command line code on line 1
third case: worked fine

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-29 15:43 UTC] wrzasq at gmail dot com
Sorry, a little misstake - of course classes B in case two and three extend classes A.
 [2010-08-29 17:19 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2010-08-29 17:19 UTC] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

There is a note in the documentation about this. See http://docs.php.net/interface

Thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 14:00:03 2025 UTC