Bug #69951 [Opn->Nab]: The function return type works for int and bool, but not for integer or boolean
| From: | nikic@php.net | Date: | Sat, 27 Jun 2015 17:21:44 +0000 |
| Subject: | Bug #69951 [Opn->Nab]: The function return type works for int and bool, but not for integer or boolean | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193942@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69951&edit=1
ID: 69951
Updated by: nikic@php.net
Reported by: nat at kolda dot org
Summary: The function return type works for int and bool, but
not for integer or boolean
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: Ubuntu Linux/Apache2
PHP Version: 7.0.0alpha2
Block user comment: N
Private report: N
New Comment:
We intentionally do not support aliases for types. You can only use bool, int, float and string.
boolean, integer, double and real are not supported.
Previous Comments:
------------------------------------------------------------------------
[2015-06-27 17:02:33] nat at kolda dot org
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 this bug report at https://bugs.php.net/bug.php?id=69951&edit=1