Re: [RFC] Patch for Union and Intersection Types

From: Date: Tue, 26 Apr 2016 17:26:05 +0000
Subject: Re: [RFC] Patch for Union and Intersection Types
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-92807@lists.php.net to get a copy of this message
On Tue, Apr 26, 2016 at 11:20 AM, Levi Morrison <morrison.levi@gmail.com> wrote: > On Tue, Apr 26, 2016 at 11:00 AM, Niklas Keller <me@kelunik.com> wrote: >> 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. > > 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.

« previous php.internals (#92807) next »