[RFC] Null Coalescing Assignment in Method Signature

From: Date: Thu, 21 Jan 2021 11:51:52 +0000
Subject: [RFC] Null Coalescing Assignment in Method Signature
Groups: php.internals 
Request: Send a blank email to internals+get-112954@lists.php.net to get a copy of this message
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 null is passed, as opposed to either having to do a null check before the function call and not passing parameter at all - or alternatively having to do something like: function foo(?array $bar = []) {     $bar ??= []; I don’t see this creating any BC incompatibilites and the ??= syntax is something already in use in PHP since 7~ I don’t have any experience with C, so would ideally love it someone could help with the development with this, or maybe point me in the right direction. I would also require RFC Karma if people are interested in opening a discussion about this (dansimkus) Thank you all for your time Regards, Daniel Simkus

« previous php.internals (#112954) next »