Req #70666 [Opn->Wfx]: Alias of int and bool not allowed in type hints
| From: | nikic@php.net | Date: | Fri, 09 Oct 2015 19:32:43 +0000 |
| Subject: | Req #70666 [Opn->Wfx]: Alias of int and bool not allowed in type hints | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196504@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70666&edit=1
ID: 70666
Updated by: nikic@php.net
Reported by: rl at nbsp dot io
Summary: Alias of int and bool not allowed in type hints
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 7.0.0RC4
Block user comment: N
Private report: N
New Comment:
As you already found, this is by design. We do not wish to provide multiple ways to write the same
thing. It cannot be changed at this point anyway, because reserving the necessary class names would
be a major BC break.
Previous Comments:
------------------------------------------------------------------------
[2015-10-08 04:54:34] rl at nbsp dot io
Description:
------------
With the new scalar type hints we cannot type hint with 'integer' or 'bool', it
seems that this was deliberately removed, as the wiki says "aliases are removed (integer and
boolean)". No reasons for the removal are given, so I hope it's not a big deal if I
request that they are added again.
It mostly comes down to coding style, I've never used the abbreviated hand versions as why
would I write 'bool' and yet 'string' or 'array'? The style
doesn't match.
Also it doesn't help that the error message is nonsensical (see the script).
Test script:
---------------
<?php
// Uncaught TypeError: Argument 1 passed to {closure}() must be an instance of integer, integer
given...
(function(integer $value) {
var_dump($value);
})('1');
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70666&edit=1