Bug #69317 [Opn]: Incorrect LSP check when extending multiple interfaces
| From: | nikic@php.net | Date: | Thu, 25 Jun 2020 08:11:31 +0000 |
| Subject: | Bug #69317 [Opn]: Incorrect LSP check when extending multiple interfaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227642@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69317&edit=1
ID: 69317
Updated by: nikic@php.net
Reported by: nikic@php.net
Summary: Incorrect LSP check when extending multiple
interfaces
Status: Open
Type: Bug
Package: Scripting Engine problem
PHP Version: master-Git-2015-03-27 (Git)
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2015-03-27 14:01:04] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69317&edit=1