|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35832 interface from extended class conflicts with interface of parent class
Submitted: 2005-12-28 22:14 UTC Modified: 2005-12-28 22:48 UTC
From: sp0n9e at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.1 OS: Windows XP
Private report: No CVE-ID: None
 [2005-12-28 22:14 UTC] sp0n9e at gmail dot com
when implementing interfaces that have common methods in a parent class and an extended class, the code below produces an error.  if i provide a method in the child class, it works.  it also works if the parent class doesn't implement its' interface.  but i think i should be able to inherit from the parent class and satisfy both interfaces.  though it would be easy in this example to "code around" the problem, i ran across this in a situation where it won't be quite as easy.

Reproduce code:
interface gotsMyMethod {
	public function myMethod();
class theparent implements gotsMyMethod {
	public function myMethod() {
		return "boo!";
interface iNeedsMyMethod {
	public function myMethod();
class child extends theparent implements iNeedsMyMethod {
$child = new child();
echo $child->myMethod();

Expected result:
I expect the code to run without any errors and output "boo!"

Actual result:
Fatal error: Can't inherit abstract function iNeedsMyMethod::myMethod() (previously declared abstract in gotsMyMethod) in C:\www\test\bug.php on line 13


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-28 22:39 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-12-28 22:48 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

function myMethod() is abstract in two different interfaces and a class can only implement the function once, hence the error.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jan 19 17:03:13 2022 UTC