Bug #76361 [Opn]: Order of extending interfaces should not matter

From: Date: Wed, 23 May 2018 12:43:40 +0000
Subject: Bug #76361 [Opn]: Order of extending interfaces should not matter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215342@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76361&edit=1 ID: 76361 Updated by: cmb@php.net Reported by: tobias dot nyholm at gmail dot com Summary: Order of extending interfaces should not matter Status: Open Type: Bug -Package: Unknown/Other Function +Package: Scripting Engine problem PHP Version: 7.2.5 Block user comment: N Private report: N New Comment: It occurs to me that this is a duplicate of bug #67270. Previous Comments: ------------------------------------------------------------------------ [2018-05-21 10:18:19] tobias dot nyholm at gmail dot com Description: ------------ If an interface that extends two other interfaces, the order of those two other interfaces should not matter. I found this bug when I was testing solutions for PSR18 and HTTPlug. Here is an 3v4l.org: https://3v4l.org/MMCL3 This bug might be related to https://bugs.php.net/bug.php?id=63816 Test script: --------------- <?php declare(strict_types=1); interface Response {} interface Request {} class RespImpl implements Response {} class ReqImpl implements Request {} interface Psr { public function sendRequest(Request $request): Response; } interface Httplug { public function sendRequest(Request $request); } //interface PsrBridge extends Psr, Httplug {} // does work interface PsrBridge extends Httplug, Psr {} // does not work class HttpClient implements PsrBridge { public function sendRequest(Request $request): Response { return new RespImpl(); } } $client = new HttpClient(); $response = $client->sendRequest(new ReqImpl()); echo $response instanceof Response ? 'OK' : 'Fail!'; Expected result: ---------------- I expect these two lines would give the same result: interface PsrBridge extends Psr, Httplug {} interface PsrBridge extends Httplug, Psr {} Actual result: -------------- Fatal error: Declaration of Httplug::sendRequest(Request $request) must be compatible with Psr::sendRequest(Request $request): Response in /in/MMCL3 on line 22 Process exited with code 255. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76361&edit=1

« previous php.bugs (#215342) next »