rfc:non_coercing_array_keys_in_strict_mode
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:non_coercing_array_keys_in_strict_mode [2017/07/27 22:30] – created wesnetmo | rfc:non_coercing_array_keys_in_strict_mode [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 8: | Line 8: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | This RFC proposes to emit a strict standards deprecation notice when PHP would coerce array keys' types (e.g. float to int), in case the page is declared using '' | + | This RFC proposes to emit a strict-standards deprecation notice when PHP would coerce array keys' types (e.g. float to int), in case the page uses '' |
For example: | For example: | ||
Line 15: | Line 15: | ||
<?php declare(strict_types = 1); | <?php declare(strict_types = 1); | ||
$array = []; | $array = []; | ||
- | $array[42.42] = 123; // Deprecated / Strict Standards: invalid key float(42.42), | + | $array[42.42] = 123; |
+ | // 7.3+ Deprecated / Strict Standards: invalid key float(42.42), | ||
+ | // 8.0+ TypeError invalid array key type " | ||
</ | </ | ||
Line 22: | Line 24: | ||
===== Impact on generics ===== | ===== Impact on generics ===== | ||
- | This proposal is friends with generics, as this change won't directly influence future decisions about generics. | + | This proposal is friends with generics, as this change won't directly influence future decisions about them. |
For example, arrays could be declared as '' | For example, arrays could be declared as '' | ||
- | However in non-strict, people will continue to rely on coercion of keys, so when type arguments are not specified, the array " | + | However in non-strict, people will continue to rely on coercion of keys, so when type arguments are not specified, the array " |
<code php> | <code php> |
rfc/non_coercing_array_keys_in_strict_mode.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1