Bug #70833 [Opn->Nab]: Scalar type hinting works with bool but not with boolean
| From: | nikic@php.net | Date: | Thu, 26 Nov 2015 19:58:33 +0000 |
| Subject: | Bug #70833 [Opn->Nab]: Scalar type hinting works with bool but not with boolean | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197444@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70833&edit=1
ID: 70833
Updated by: nikic@php.net
Reported by: sam at rmcreative dot ru
Summary: Scalar type hinting works with bool but not with
boolean
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Any
PHP Version: 7.0.0RC6
Block user comment: N
Private report: N
New Comment:
As per the previous comments, not supporting aliases is deliberate, so closing as not a bug.
Previous Comments:
------------------------------------------------------------------------
[2015-11-26 19:41:45] webmaster at tubo-world dot de
As stated, the aliases are not meant to be supported according to the RFC. This can be closed.
------------------------------------------------------------------------
[2015-11-02 10:03:47] php at developerjack dot com
My understanding is only one scalar type should exist.
From the RFC:
https://wiki.php.net/rfc/scalar_type_hints_v5
Heading: "Type Aliases Should Not Be Supported"
> This proposal takes the stance that there should be one obvious type. Therefore, no aliases are
> supported.
I cannot remember a separate RFC to reserve boolean (or integer for that matter) for use.
------------------------------------------------------------------------
[2015-11-02 09:24:28] sam at rmcreative dot ru
Description:
------------
You can cast to boolean using either (bool)$var or (boolean)$var. In scalar type hints currently
only bool could be used which is inconsistent.
Test script:
---------------
<?php
$boolean = 1;
$boolean = (boolean) $boolean;
function dump_boolean(boolean $var)
{
var_dump($var);
}
dump_boolean($boolean);
// https://3v4l.org/Cdtoe
Expected result:
----------------
I'd expect both boolean and bool work as scalar type hint because both work well for type
casting.
Actual result:
--------------
https://3v4l.org/egb59
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70833&edit=1