rfc:remove_hex_support_in_numeric_strings
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:remove_hex_support_in_numeric_strings [2015/01/01 03:03] – Fixed pull request link ajf | rfc:remove_hex_support_in_numeric_strings [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Date: 2014-08-19 | * Date: 2014-08-19 | ||
* Author: Nikita Popov < | * Author: Nikita Popov < | ||
- | * Status: | + | * Status: |
- | * Target version: | + | |
===== Introduction ===== | ===== Introduction ===== | ||
- | This RFC proposes to remove support for hexadecimal numers in '' | + | This RFC proposes to remove support for hexadecimal numers in '' |
PHP internally has two primary methods from converting strings into numbers: | PHP internally has two primary methods from converting strings into numbers: | ||
- | The first, and most commonly used, are direct casts to the integer or float types ('' | + | The first, and most commonly used, are direct casts to the integer or float types ('' |
<code php> | <code php> | ||
Line 22: | Line 21: | ||
This leads to a discrepancy in behavior between type casts and behavior when '' | This leads to a discrepancy in behavior between type casts and behavior when '' | ||
- | === is_numeric function === | + | === is_numeric() function === |
<code php> | <code php> | ||
Line 30: | Line 29: | ||
} | } | ||
- | // Exception not thrown, instead wrong result is taken here: | + | // Exception not thrown, instead wrong result is generated |
$n = (int) $str; // 0 | $n = (int) $str; // 0 | ||
</ | </ | ||
Line 39: | Line 38: | ||
var_dump(' | var_dump(' | ||
- | var_dump((int) ' | + | var_dump((int) ' |
</ | </ | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | This RFC proposes to remove support for hexadecimal numbers | + | This RFC proposes to remove support for hexadecimal numbers |
- | An alternative approach would be to add hexadecimal support for integer/ | + | An alternative approach would be to add hexadecimal support for integer/ |
Generally hexadecimal strings are not often necessary and should be explicitly handled in the cases where they are. A robust way of both validating and parsing hexadecimal strings is given by '' | Generally hexadecimal strings are not often necessary and should be explicitly handled in the cases where they are. A robust way of both validating and parsing hexadecimal strings is given by '' | ||
Line 54: | Line 53: | ||
Hexadecimal numbers in strings are no longer supported in the following contexts: | Hexadecimal numbers in strings are no longer supported in the following contexts: | ||
- | * The '' | + | * The '' |
* Operands of the '' | * Operands of the '' | ||
* Arguments of internal functions using '' | * Arguments of internal functions using '' | ||
+ | * Probably some other fringe cases. | ||
Hex string arguments to internal functions will throw the customary "non well formed numeric string" | Hex string arguments to internal functions will throw the customary "non well formed numeric string" | ||
Line 65: | Line 65: | ||
===== Vote ===== | ===== Vote ===== | ||
+ | |||
+ | As this is a language change a 2/3 majority is required. | ||
+ | |||
+ | The vote started on 2015-01-17 and ends on 2015-01-27. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
rfc/remove_hex_support_in_numeric_strings.1420081396.txt.gz · Last modified: 2017/09/22 13:28 (external edit)