Re: [RFC] Patch for Union and Intersection Types
| From: | Bob Weinand | Date: | Tue, 26 Apr 2016 17:33:07 +0000 |
| Subject: | Re: [RFC] Patch for Union and Intersection Types | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92808@lists.php.net to get a copy of this message | ||
> Am 26.04.2016 um 19:00 schrieb Niklas Keller <me@kelunik.com>:
>
> 2016-04-26 16:58 GMT+02:00 Bob Weinand <bobwei9@hotmail.com>:
>
>> Yeah, I'd like to not allow ?Foo in any case if union types pass.
>>
>
> What's the reason for that? To me, null is neither a type nor should it be.
I don't want to argue that now, but null most definitely IS a type. It is the null type with a
single value, null, whose semantics is to represent the absence of any other value.
There's also plenty of evidence in PHP that null is considered a type: get_type(), https://php.net/null, has it's own is_* function etc.
At least in the PHP ecosystem it is considered its own type. Other type systems may not, but the one
of PHP does.
Thus, we are definitely considering it as a type - a question for you: What's the type of the
value null then, if not null?
If we wouldn't make a distinction between null and an object (i.e. allow null to be passed to a
function(Foo $foo) {}), it could be considered a supervalue of type object. But that's not the
case.
Bob