php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39403 A class can't implements interface implemented by implemented interface/classes
Submitted: 2006-11-06 16:48 UTC Modified: 2006-11-11 00:00 UTC
Votes:6
Avg. Score:5.0 ± 0.0
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:1 (20.0%)
From: baldurien at bbnwn dot eu Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.0 OS: Irrelevant
Private report: No CVE-ID: None
 [2006-11-06 16:48 UTC] baldurien at bbnwn dot eu
Description:
------------
Hi,

Since php5.2, all my classes have error due to something that changed in php5.2 : 

Fatal error: Class XtfLexer cannot implement previously implemented interface XtfParserRegistrable 

The reason of that ?

Well take a look at the classes (the code does not interest you as it's not the problem)

interface XtfParserRegistrable {}
interface XtfHeaderHandler extends XtfParserRegistrable {}
class XtfLexer implements XtfHeaderHandler, XtfParserRegistrable {}

Because the interface extends XtfParserRegistrable, the XtfLexer can not implements XtfParserRegistrable itself.

This is STUPID, REALLY STUPID.

What happens if one day I change the interface/classes I implements/extends, and if I still wish to benefit from one interface that is *possibly* implemented by my parents interfaces/classes?

Well : it will fails.

Reproduce code:
---------------
Try this :

interface XtfParserRegistrable {}
interface XtfHeaderHandler extends XtfParserRegistrable {}
class XtfLexer implements XtfHeaderHandler, XtfParserRegistrable {}


Expected result:
----------------
We can implements interface implemented by parent class/interface, and no (fatal) error should be thrown.

Actual result:
--------------
We can't.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-11 00:00 UTC] tony2001@php.net
That's right, you can't implement an interface twice, that just doesn't make any sense.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC