rfc:destructuring_coalesce

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:destructuring_coalesce [2022/11/05 13:02] bwoebirfc:destructuring_coalesce [2022/11/26 15:07] (current) – updated status. danack
Line 3: Line 3:
   * Date: 2022-10-14   * Date: 2022-10-14
   * Author: Bob Weinand <bwoebi@php.net>   * Author: Bob Weinand <bwoebi@php.net>
-  * Status: Under discussion+  * Status: Declined
   * First Published at: http://wiki.php.net/rfc/destructuring_coalesce   * First Published at: http://wiki.php.net/rfc/destructuring_coalesce
  
Line 27: Line 27:
 [[$a, $b] ?? [1, 2]] = $array; // if $array[0] is null or does not exist, $a will be 1 and $b will be 2 [[$a, $b] ?? [1, 2]] = $array; // if $array[0] is null or does not exist, $a will be 1 and $b will be 2
 </PHP> </PHP>
 +
 +Also note that, equivalently to how ''??'' operates, the right-hand side is not evaluated at all, if the respective key exists and is not null in the source array.
  
 ==== Use cases ==== ==== Use cases ====
 +
 Exploding an externally provided string, e.g. a key-value pair separated by ''='': Exploding an externally provided string, e.g. a key-value pair separated by ''='':
 <PHP> <PHP>
Line 152: Line 155:
 There's no BC break, not even a parser change, only not emitting a compiler error for coalesce in destructuring assignments. There's no BC break, not even a parser change, only not emitting a compiler error for coalesce in destructuring assignments.
  
-===== Proposed Voting Choices =====+===== Vote =====
  
-Add a destructuring coalesce feature as described?+A 2/3 majority is required. The vote started 2022-11-07 and ended 2022-11-21.
  
-A 2/3 majority is required.+<doodle title="Add a destructuring coalesce feature as described?" auth="bwoebi" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
 ===== Implementation ===== ===== Implementation =====
rfc/destructuring_coalesce.1667653336.txt.gz · Last modified: 2022/11/05 13:02 by bwoebi