php.net |  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: -
From: nikic@php.net 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
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nikic@php.net
New email:
PHP Version: OS:

 

 [2015-03-27 14:01 UTC] nikic@php.net
Description:
------------
<?php

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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Oct 20 18:01:27 2019 UTC