php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71358 Order of interfaces is meaningful
Submitted: 2016-01-13 12:57 UTC Modified: 2016-03-26 21:50 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: danack@php.net Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: 7.0.2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 - 5 = ?
Subscribe to this entry?

 
 [2016-01-13 12:57 UTC] danack@php.net
Description:
------------
The check for whether a class is valid or not is dependent on what order the interfaces it implements are declared.

The example below is simple, to show the bug clearly.

A more realistic case would involve having multiple classes that implement various interfaces, including the "\Serializable" interface, and then realising that one of the user-defined interfaces should actually extend "\Serializable".

This would make some code break, depending on what order the implements interfaces was written as.

Test script:
---------------
interface Base
{
    const FOO = 5;
    function base();
}

interface Derived extends Base {
    function derived();
}

class ThisIsValid implements Base, Derived {
    public function base() {}
    public function derived() {}
}

class ThisWillError implements Derived, Base {
    public function base() {}
    public function derived() {}
}

Expected result:
----------------
No error, the definition of implements interfaces should not affect compilation.

Actual result:
--------------
Fatal error: Class ThisWillError cannot implement previously implemented interface Base in /in/Anc6g on line 18

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-14 13:05 UTC] danack@php.net
Closing as duplicate of https://bugs.php.net/bug.php?id=63816 which I will update the status on.
 [2016-03-26 21:50 UTC] krakjoe@php.net
-Status: Open +Status: Duplicate
 [2016-03-26 21:50 UTC] krakjoe@php.net
I think Dan forgot to update status ...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC