rfc:typecast_array_desctructuring

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:typecast_array_desctructuring [2020/04/08 09:26]
wol-soft Added motivation and discussion section
rfc:typecast_array_desctructuring [2020/04/23 08:40] (current)
wol-soft
Line 4: Line 4:
   * Target Version: PHP 8.0   * Target Version: PHP 8.0
   * Author: Enno Woortmann, enno.woortmann@web.de   * Author: Enno Woortmann, enno.woortmann@web.de
-  * Status: Under Discussion +  * Status: Declined 
-  * First Published athttp://wiki.php.net/rfc/typecast_array_desctructuring+  * Implementationhttps://github.com/php/php-src/pull/5296
  
 ===== Introduction ===== ===== Introduction =====
Line 130: Line 130:
  
 <code php> <code php>
-// simple reference assignment cast+// reference assignment cast
 $now = "2020"; $now = "2020";
 $now2 = (int) &$now; $now2 = (int) &$now;
Line 139: Line 139:
 </code> </code>
  
-Future scopes may include strict type casts:+---- 
 + 
 +Future scopes may include strict type casts which avoid eg. (!int) "No Number String" to be casted to 0:
  
 <code php> <code php>
-// simple strict assignment cast+// strict assignment cast
 $now = "2020"; $now = "2020";
 $now2 = (!int) $now; $now2 = (!int) $now;
  
-// simple strict assignment cast combined with array destructuring+// strict assignment cast combined with array destructuring
 $years = ["2020", "2021"]; $years = ["2020", "2021"];
 [(!int) $now, (!int) $future] = $years; [(!int) $now, (!int) $future] = $years;
 </code> </code>
 +
 +----
 +
 +Future scopes may include nullable type casts (compare https://wiki.php.net/rfc/nullable-casting):
 +
 +<code php>
 +// nullable assignment cast
 +$now = "2020";
 +$now2 = (?int) $now;
 +
 +// nullable assignment cast combined with array destructuring
 +$years = ["2020", "2021", null];
 +[(?int) $now, (?int) $future, (?int) $evenLater] = $years;
 +</code>
 +
 +----
  
 Future scopes may include regular type checks which depend on strict_types directive: Future scopes may include regular type checks which depend on strict_types directive:
Line 160: Line 178:
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
  
-Vote will require 2/3 majority.+Voting starts 2020-04-09 and ends 2020-04-23. 
 + 
 +As this is a language change, a 2/3 majority is requiredThe vote is a straight Yes/No vote for accepting the RFC and merging the patch. 
 + 
 +<doodle title="Add type casting in array destructuring expressions" auth="wol-soft" voteType="single" closed="true"> 
 +   * yes 
 +   * no 
 +</doodle> 
 + 
 +---- 
 + 
 +As the future scopes section of this proposal includes a lot of possible topics an additional poll to see which of these topics may be tackled in the near future: 
 + 
 +<doodle title="Choose one or more of the suggested future scopes in which you are interested" auth="wol-soft" voteType="multi" closed="true"> 
 +   * reference assignment casts 
 +   * strict casts 
 +   * nullable casts 
 +   * type checks in array destructuring expressions 
 +   * none 
 +</doodle>
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
rfc/typecast_array_desctructuring.1586338011.txt.gz · Last modified: 2020/04/08 09:26 by wol-soft