|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69317 Incorrect LSP check when extending multiple interfaces
Submitted: 2015-03-27 14:01 UTC Modified: 2020-06-25 08:11 UTC
From: Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: master-Git-2015-03-27 (Git) 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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
38 + 33 = ?
Subscribe to this entry?

 [2015-03-27 14:01 UTC]

class X {}

interface A extends IteratorAggregate {
    function getIterator() : X;

interface B extends IteratorAggregate, A {


Fatal error: Declaration of IteratorAggregate::getIterator() must be compatible with A::getIterator(): X in /home/nikic/php-src/t030.php on line 9

This happens because we first inherit the IteratorAggregate::getIterator() method and then check it against the A::getIterator() method - which is of course wrong.

This is a problem with return types, because they are not fully invariant - not sure if it might also be a problem for some things before PHP 7.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-25 08:11 UTC]
This problems still exists. It's also not clear how to fix it, especially with covariance in PHP 7.4. We no longer have a way to just pick the "more specific" method, because variance might be unresolved at the time.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 17:01:30 2024 UTC