RE: [PHP-DEV] Introducing "Array Of" RFC

From: Date: Thu, 16 Jan 2014 00:09:29 +0000
Subject: RE: [PHP-DEV] Introducing "Array Of" RFC
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-71164@lists.php.net to get a copy of this message
> -----Original Message----- > From: Andrea Faulds [mailto:ajf@ajf.me] > Sent: Thursday, January 16, 2014 12:54 AM > To: Crypto Compress; internals@lists.php.net > Subject: Re: [PHP-DEV] Introducing "Array Of" RFC > > > > On 15/01/14 23:18, Crypto Compress wrote: > > e.g.: function foo(Bar[null] = null) > > I'd prefer the ? syntax for nullables that C# has. I'm imagining > something like this: > > function foo(Bar? $a) {} // $a is Bar/null > function foo(Bar?[] $a) {} // $a is array of Bars/nulls > function foo(Bar[]? $a) {} // $a is array of Bars, or null > function foo(Bar?[]? $a) {} // $a is array of Bars/nulls, or null > > -- > Andrea Faulds > http://ajf.me/ > > -- I like Andrea's proposal, this way we can support all scenarios. It is possible to define that NULL is a valid entry in an array and we would stick to the same decision as for actual parameters, namely that one has to define explicitly that null is a valid entry. This would make me happy and I suppose also Philip. Just as side notice, this syntax would also give the chance for PHP to get rid of the double meaning of "=null" in a later version. I am talking about the following case: function foo(Foo $a=null, $b=1){} Where one might not want to specify that $a is optional but cannot do it differently at the moment - with the additional ? it could change :)

« previous php.internals (#71164) next »