Bug #78677 [NEW]: Interface declaration of ... unexpected behavior

From: Date: Thu, 17 Oct 2019 07:41:20 +0000
Subject: Bug #78677 [NEW]: Interface declaration of ... unexpected behavior
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223218@lists.php.net to get a copy of this message
From: pavel at bunaev dot ru Operating system: 18.04.1-Ubuntu PHP version: 7.2.23 Package: *Programming Data Structures Bug Type: Bug Bug description:Interface declaration of ... unexpected behavior Description: ------------ The interface allows you to change the type of variable in an incompatible direction. In versions php 7.0+ and 7.1-, we could specify in the interface with what types of data we will work in the method. And at the kernel level, be sure that by implementing the interface the signature will not change. In version php 7.2+ and 7.3+, this has changed and there was no announcement .. We can create an interface and expect in the signature that the method will work with certain arguments but in fact we can transfer anything OS linux version php 7.2+ version php 7.1- is ok Test script: --------------- <?php interface IBaz {}; interface IFoo { public function simple(IBaz $a); } class CFoo implements IFoo { public function simple($a){ var_dump($a); } } $cFoo = new CFoo(); $cFoo->simple('vbvc'); Expected result: ---------------- <br /> <b>Fatal error</b>: Declaration of CFoo::simple($a) must be compatible with IFoo::simple(IBaz $a) in <b>[...][...]</b> on line <b>7</b><br /> Actual result: -------------- string(4) "vbvc" -- Edit bug report at https://bugs.php.net/bug.php?id=78677&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78677&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78677&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78677&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78677&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78677&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78677&r=support Expected behavior: https://bugs.php.net/fix.php?id=78677&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78677&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78677&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78677&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78677&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78677&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78677&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78677&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78677&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78677&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78677&r=mysqlcfg

« previous php.bugs (#223218) next »