Re: [PHP7][Bug?] What is the difference between 'boolean' and 'bool'?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Harkness:

> It definitely looks like PHP is treating "boolean" as a class name rather
> than a synonym for the "bool" scalar type. Sticking to "bool" seems to
> avoid the problem. Have you run into any cases where using "bool" fails? I
> recommend submitting a bug report to either make "boolean" work or remove
> it.

There has already been at least one closely related report[1], and this
has been tagged as "not a bug", so it probably doesn't make sense to
report the issue again. :)

> It's interesting that they chose to disallow null values for scalar
> parameters, unlike classes and arrays. It would be nice to allow null by
> using something like this: function bar(bool? $foo) {...}

This suggestion has been made on php-internals (IIRC multiple times),
but obviously has been rejected for now. Note that NULL is acceptable if
given as default argument, though[2][3].

[1] <https://bugs.php.net/bug.php?id=69951>
[2] <https://3v4l.org/MG1WU>
[3]
<http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration>

-- 
Christoph M. Becker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux