Re: Typed properties patch

From: Date: Fri, 15 Apr 2016 21:01:25 +0000
Subject: Re: Typed properties patch
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-92352@lists.php.net to get a copy of this message
Hi all, On Thu, Apr 7, 2016 at 9:44 PM, Bob Weinand <bobwei9@hotmail.com> wrote: >> 1) While parameters allow null to be accepted as the default value, null is never a valid >> value for a typed property. >> >> I think we must have a way to make properties explicitly nullable. Otherwise we won't >> be able to define even simple binary tree... >> >> class Node { >> >> public Node $left = null; >> public Node $right = null; >> } > > Eventually that, but I honestly would prefer to be more explicit with a typed union > > public Node | null $left; Value must be able to be NULL. SQL has "NOT NULL" constraint. We may have "MAY NULL" and this syntax seems reasonable choice. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#92352) next »