Re: [PHP-DEV] [RFC] Null Coalescing Assignment in Method Signature

2021-01-21 Thread Larry Garfield
On Thu, Jan 21, 2021, at 4:37 PM, Sara Golemon wrote: > On Thu, Jan 21, 2021 at 3:29 PM Larry Garfield > wrote: > > > > I'm unclear why you'd allow null at all then. > > If you want $bar to be optional, and to be an empty array if not > specified, then just do: > > > > function foo(array $bar =

Re: [PHP-DEV] [RFC] Null Coalescing Assignment in Method Signature

2021-01-21 Thread Sara Golemon
On Thu, Jan 21, 2021 at 3:29 PM Larry Garfield wrote: > > I'm unclear why you'd allow null at all then. > If you want $bar to be optional, and to be an empty array if not specified, then just do: > > function foo(array $bar = []) { ... } > > At that point, the only thing adding ?array does is

Re: [PHP-DEV] [RFC] Null Coalescing Assignment in Method Signature

2021-01-21 Thread Rowan Tommins
On 21/01/2021 21:28, Larry Garfield wrote: I'm unclear why you'd allow null at all then. If you want $bar to be optional, and to be an empty array if not specified, then just do: function foo(array $bar = []) { ... } At that point, the only thing adding ?array does is allow you to explicitly

Re: [PHP-DEV] [RFC] Null Coalescing Assignment in Method Signature

2021-01-21 Thread Larry Garfield
On Thu, Jan 21, 2021, at 5:51 AM, Daniel Simkus wrote: > Hello all, > > I am writing to see if anyone is interested in an RFC for ability to > automatically coalesce nullable method parameters with the supplied > default. It would look something like this: > > function foo(?array $bar ??= [])

[PHP-DEV] [RFC] Null Coalescing Assignment in Method Signature

2021-01-21 Thread Daniel Simkus
Hello all, I am writing to see if anyone is interested in an RFC for ability to automatically coalesce nullable method parameters with the supplied default. It would look something like this: function foo(?array $bar ??= []) { This would result in $bar automatically converting to an array if