Bug #69951 [NEW]: The function return type works for int and bool, but not for integer or boolean

From: Date: Sat, 27 Jun 2015 17:02:35 +0000
Subject: Bug #69951 [NEW]: The function return type works for int and bool, but not for integer or boolean
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193939@lists.php.net to get a copy of this message
From: nat at kolda dot org Operating system: Ubuntu Linux/Apache2 PHP version: 7.0.0alpha2 Package: Class/Object related Bug Type: Bug Bug description:The function return type works for int and bool, but not for integer or boolean Description: ------------ The function return type works for int and bool, but not for integer or boolean. Test script: --------------- <?php // This function works fine. function foo(): int { return 2; } // This function does not work because of integer instead of int. function bar(): integer { return 3; } // This function works fine. function baz(): bool { return true; } // This function does not work because of boolean instead of bool. function foobar(): boolean { return false; } echo foo(); // Works fine. echo bar(); // Fatal error: Uncaught TypeError: Return value of bar() must be an // instance of integer, integer returned in // /var/www/html/index.php on line 7 in // /var/www/html/index.php:7 Stack trace: #0 // /var/www/html/index.php(19): bar() #1 {main} thrown in // /var/www/html/index.php on line 7 echo baz(); // Works fine. echo foobar(); // Fatal error: Uncaught TypeError: Return value of foobar() must // be an instance of boolean, boolean returned in // /var/www/html/index.php on line 15 in // /var/www/html/index.php:15 Stack trace: #0 // /var/www/html/index.php(21): foobar() #1 {main} thrown in // /var/www/html/index.php on line 15 -- Edit bug report at https://bugs.php.net/bug.php?id=69951&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69951&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69951&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69951&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69951&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69951&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69951&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69951&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69951&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69951&r=support Expected behavior: https://bugs.php.net/fix.php?id=69951&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69951&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69951&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69951&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69951&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69951&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69951&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69951&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69951&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69951&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69951&r=mysqlcfg

« previous php.bugs (#193939) next »