Bug #71978 [NEW]: Existence of return type hint affects other compatibility rules

From: Date: Wed, 06 Apr 2016 13:56:40 +0000
Subject: Bug #71978 [NEW]: Existence of return type hint affects other compatibility rules
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200401@lists.php.net to get a copy of this message
From: dmitry Operating system: * PHP version: 7.0Git-2016-04-06 (Git) Package: Scripting Engine problem Bug Type: Bug Bug description:Existence of return type hint affects other compatibility rules Description: ------------ Children classes may override methods with different argument types. This leads to Warning. However if the same methods in addition have the same return type PHP emits "Fatal Error" instead of "Warning" Test script: --------------- <?php class A { function foo(int $a) {} } class B extends A { function foo(string $a) {} } class A1 { function foo(int $a): int {} } class B1 extends A1 { function foo(string $a): int {} } ?> Expected result: ---------------- Warning: Declaration of B::foo(string $a) should be compatible with A::foo(int $a) in %s on line %d Warning: Declaration of B1::foo(string $a): int should be compatible with A1::foo(int $a): int in %s on line %d Actual result: -------------- Warning: Declaration of B::foo(string $a) should be compatible with A::foo(int $a) in %s on line %d Fatal Error: Declaration of B1::foo(string $a): int must be compatible with A1::foo(int $a): int in %s on line %d -- Edit bug report at https://bugs.php.net/bug.php?id=71978&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71978&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71978&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71978&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71978&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71978&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71978&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71978&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71978&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71978&r=support Expected behavior: https://bugs.php.net/fix.php?id=71978&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71978&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71978&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71978&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71978&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71978&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71978&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71978&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71978&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71978&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71978&r=mysqlcfg

« previous php.bugs (#200401) next »