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

From: Date: Mon, 21 May 2018 10:18:23 +0000
Subject: Bug #76361 [NEW]: Order of extending interfaces should not matter
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215316@lists.php.net to get a copy of this message
From: tobias dot nyholm at gmail dot com Operating system: PHP version: 7.2.5 Package: Unknown/Other Function Bug Type: Bug Bug description:Order of extending interfaces should not matter 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 bug report at https://bugs.php.net/bug.php?id=76361&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76361&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76361&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76361&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76361&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76361&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76361&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76361&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76361&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76361&r=support Expected behavior: https://bugs.php.net/fix.php?id=76361&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76361&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76361&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76361&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76361&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76361&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76361&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76361&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76361&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76361&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76361&r=mysqlcfg

« previous php.bugs (#215316) next »