That's just wrong. Boolean is the type. False is just one possibile value of that type.
That's just wrong. Boolean is the type. False is just one possibile value of that type.
PHP isn't exacly an "everything is an object" language, but it's been slowly moving in that direction for years, replacing most callables, resources, etc. with corresponding objects. I wouldn't be surprised if the designers are approaching this issue with an object-oriented mindset, though it still feels wrong to make an exception for only one half of a boolean pair.
The introduction of the RFC [2] also still mentions `false` is of type bool:
> null corresponds to PHP's unit type, i.e. the type which holds a single value. false is a literal type of type bool.
But why call it bool if `true` is not a standalone type too?
[1] https://docs.python.org/3/library/typing.html#typing.Literal
It’s not really conflation when php has been doing that since forever as it originally was little more than a thin shim over C (you can see that in lots of older APIs e.g. the mysql_ stuff is straight transcribed from the C library).
On a little more serious note, Perl is an earlier language and even more closely tied to C tradition. Many (but not all) of its built-ins and library functions and methods return undef rather than 0 for failure.
Having false and true be singleton types is perfectly cromulent.
That's how Smalltalk has been doing it for 40 years, and why it can do without control structures:
Boolean subclass: False [
ifTrue: trueBlock ifFalse: falseBlock [
^falseBlock value
]
"..."
Boolean subclass: True [
ifTrue: trueBlock ifFalse: falseBlock [
^trueBlock value
]
"..."