Re: intersection types and null for defaults, properties and return types

From: Date: Mon, 19 Jul 2021 14:26:16 +0000
Subject: Re: intersection types and null for defaults, properties and return types
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-115493@lists.php.net to get a copy of this message
On Mon, Jul 19, 2021 at 4:05 PM Larry Garfield <larry@garfieldtech.com> wrote: > > I can see the argument that "I need something with these two interfaces... > or nothing" is a valid use case to care about. However, as Saif noted, > this is a side effect of the inability to mix union and intersection types. > > So, my question would be, how feasible will it be in the future to > introduce that mixing? If it's something that is likely to show up in 8.2 > or 8.3, we may be better off going "meh" for now and letting a solution > fall out naturally later. If it's something that could take a decade, then > figuring out a way to special case "or null" in the meantime is probably > worthwhile. (I don't know what the best way to do that is.) > You made me remember that [we had non-scalar parameter type declarations since PHP 5, and] we got scalar type declarations and return type declarations in 7.0 but nullable type declarations "only" in 7.1 (but I agree). -- Guilliam Xavier

« previous php.internals (#115493) next »