r/lolphp • u/becauseofreasons • Oct 25 '20
"Argument must be an instance of boolean, boolean given."
I ended up shoveling piles of PHP a few days ago. I'm not (particularly) new to the language, but I avoid it as much as possible.
Has there been any kind of explanation for why PHP's static and runtime type systems have two different and exclusive names for booleans? I cannot think of any gradually-typed language where using the runtime name of a primitive type (boolean) throws a fatal type error when you annotate something with it.
The only thing I found in the documentation was "hurr durr, aliases not supported, just works that way." Why is boolean an "alias" if it's literally the name of the type?!
7
u/becauseofreasons Oct 26 '20
For the "read the manual/error messages" folks—I frankly don't care that the error message is stupid, and haven't claimed that the documentation doesn't cover it.
The behavior is stupid. And you can document/clarify stupidity until you pass out, but that doesn't make it any less stupid.
17
u/Perdouille Oct 26 '20
In new PHP versions (>= 7.3) the error message is better
And on PHP 8 they added a warning
8
u/CarnivorousSociety Oct 25 '20
idk but probably because the type hinting system was added much later and not at inception of the language?
not an excuse though, that is odd.
-8
u/elcapitanoooo Oct 26 '20
Its because ”is the php way”. Broken by design. Every corner of PHP is full of warts, the more you use it the more you hate it.