On Tue, Apr 26, 2016 at 11:20 AM, Levi Morrison <morrison.l...@gmail.com> wrote:
> On Tue, Apr 26, 2016 at 11:00 AM, Niklas Keller <m...@kelunik.com> wrote:
>> 2016-04-26 16:58 GMT+02:00 Bob Weinand <bobw...@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.
>
> On the contrary, our manual says:
>
>> NULL is the only possible value of type null.
>
> And internally it is also a distinct type.
>
> It's been this way for a long time; we just haven't permitted `null`
> as a type declaration because until now it has been useless.

To further expand on why it was previously useless:

    function foo(Null $a) {
        return $a;
    }

There is only one possibility for this parameter, which is the value
`NULL`. There is hardly any value to it when you can just write this
instead:

    function foo() {
        return NULL;
    }

In words: if the only possible value for a parameter is null then it's
not really a parameter; it's just a constant value and doesn't need to
be parameterized.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to