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

From: Date: Thu, 17 Dec 2015 08:55:06 +0000
Subject: Re: [PHP7][Bug?] What is the difference between 'boolean' and 'bool'?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-325298@lists.php.net to get a copy of this message
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

« previous php.general (#325298) next »