|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34807 Interface is forced on child classes even though parent class has implemented.
Submitted: 2005-10-10 12:27 UTC Modified: 2005-10-10 20:20 UTC
From: daarius at hotmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: daarius at hotmail dot com
New email:
PHP Version: OS:


 [2005-10-10 12:27 UTC] daarius at hotmail dot com
The interface of a parent class is also forced to be implemented on to the children classes if they use methods with same name as in Interface. Even though the parent class has implemented the methods declared in the Interface legally.

Reproduce code:
interface MyInterface {
   public function Z($s);

class MyClass implements MyInterface {
   public function Z($s) {}

class MySubClass extends MyClass {
   public function Z() {}

Expected result:
Above should be legal (at least i think), because parent is implementing the interface, the child is just extending the parent's method.

But, if we remove the method completely from child class, then there is no error message and Interface is no longer being forced on to child. This suggests inconsistency.

Also, if we remove the interface from the code, then the parent child extension of the same method name is still legal, as the number of arguments is not being checked anymore.

Actual result:
Fatal error: Declaration of MySubClass::Z() must be compatible with that of MyInterface::Z() in C:\httpd\PHPObject3.0\index.php on line 12


Add a Patch

Pull Requests

Add a Pull Request


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

 [2005-10-10 16:01 UTC] daarius at hotmail dot com
I have tried the latest snapshot. The error is some on there too.
 [2005-10-10 20:20 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

You cannot redeclare methods in PHP. Reread the error message.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Sep 27 11:01:23 2020 UTC