rfc:typecast_array_desctructuring
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:typecast_array_desctructuring [2020/04/08 09:26] – Added motivation and discussion section wol-soft | 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: | + | * Status: |
- | * First Published at: http://wiki.php.net/rfc/typecast_array_desctructuring | + | * Implementation: https://github.com/php/php-src/ |
===== Introduction ===== | ===== Introduction ===== | ||
Line 130: | Line 130: | ||
<code php> | <code php> | ||
- | // simple | + | // reference assignment cast |
$now = " | $now = " | ||
$now2 = (int) &$now; | $now2 = (int) &$now; | ||
Line 139: | Line 139: | ||
</ | </ | ||
- | Future scopes may include strict type casts: | + | ---- |
+ | |||
+ | Future scopes may include strict type casts which avoid eg. (!int) "No Number String" | ||
<code php> | <code php> | ||
- | // simple | + | // strict assignment cast |
$now = " | $now = " | ||
$now2 = (!int) $now; | $now2 = (!int) $now; | ||
- | // simple | + | // strict assignment cast combined with array destructuring |
$years = [" | $years = [" | ||
[(!int) $now, (!int) $future] = $years; | [(!int) $now, (!int) $future] = $years; | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Future scopes may include nullable type casts (compare https:// | ||
+ | |||
+ | <code php> | ||
+ | // nullable assignment cast | ||
+ | $now = " | ||
+ | $now2 = (?int) $now; | ||
+ | |||
+ | // nullable assignment cast combined with array destructuring | ||
+ | $years = [" | ||
+ | [(?int) $now, (?int) $future, (?int) $evenLater] = $years; | ||
+ | </ | ||
+ | |||
+ | ---- | ||
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 | + | Voting starts 2020-04-09 and ends 2020-04-23. |
+ | |||
+ | As this is a language change, a 2/3 majority | ||
+ | |||
+ | <doodle title=" | ||
+ | * yes | ||
+ | * no | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | 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=" | ||
+ | * reference assignment casts | ||
+ | * strict casts | ||
+ | * nullable casts | ||
+ | * type checks in array destructuring expressions | ||
+ | * none | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== |
rfc/typecast_array_desctructuring.1586338011.txt.gz · Last modified: 2020/04/08 09:26 by wol-soft