Web lists-archives.com

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




My bad! I totally missed the gist link.

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.

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) {...}

BTW, I love the quirky yet logical error message "Argument 1 passed to
bar() must be an instance of boolean, boolean given".

David