rfc:zpp-conversion-rules
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:zpp-conversion-rules [2015/02/21 00:22] – francois | rfc:zpp-conversion-rules [2021/03/27 14:25] (current) – Move to inactive ilutov | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Type parsing modifications ====== | ====== PHP RFC: Type parsing modifications ====== | ||
- | * Version: 0.3 | + | * Version: 0.4 |
- | * Date: 2015-02-21 | + | * Date: 2015-02-22 |
* Author: François Laupretre, francois@php.net | * Author: François Laupretre, francois@php.net | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 9: | Line 9: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | This RFC proposes changes in the mechanism used to parse internal function arguments. | + | This RFC proposes changes in the ruleset used to filter |
- | + | and convert input arguments to internal functions. | |
- | The main change proposed here is a modification of the ruleset used to filter | + | |
- | and implicitly | + | |
- | + | ||
- | Then, minor additions to be used by the userland type hinting system are proposed. | + | |
===== History ===== | ===== History ===== | ||
Line 69: | Line 65: | ||
* Disable IS_FALSE/ | * Disable IS_FALSE/ | ||
- | * Disable any conversion | + | * IS_STRING |
* Disable IS_NULL to be accepted for any ZPP type except the new ' | * Disable IS_NULL to be accepted for any ZPP type except the new ' | ||
* Disable (IS_DOUBLE -> long) if the fractional part of the input value is non null. | * Disable (IS_DOUBLE -> long) if the fractional part of the input value is non null. | ||
Line 85: | Line 81: | ||
^ ^ Zval type ^^^^^^^^ | ^ ^ Zval type ^^^^^^^^ | ||
^ ZPP type ^ IS_NULL | ^ ZPP type ^ IS_NULL | ||
- | ^ null | < | + | ^ null | < |
- | ^ bool | - | < | + | ^ bool | - | < |
- | ^ long | - | + | ^ long | - |
- | ^ double | + | ^ double |
- | ^ string | + | ^ string |
- | * (1) error if fractional part is non null | + | * (1) false if null, true if non null |
- | * (2) Run string through is_numeric_str_function() and detect error. If double with null fractional part returned, convert to long, else error | + | * (2) error if fractional part is non null |
- | * (3) Run string through is_numeric_str_function() and detect error. If int returned, convert to double | + | * (3) Run string through is_numeric_str_function() and detect error. If double with null fractional part returned, convert to long, else error |
+ | * (4) Run string through is_numeric_str_function() and detect error. If int returned, convert to double | ||
+ | * (5) If string is numeric and contains a representation of a null number (anything that would convert to 0 or 0.0), or if string is empty, -> false, otherwise -> true. | ||
and the new behavior of _is_numeric_string_ex() : | and the new behavior of _is_numeric_string_ex() : | ||
Line 99: | Line 97: | ||
* Ignore trailing blanks | * Ignore trailing blanks | ||
* Error on any non-blank trailing char | * Error on any non-blank trailing char | ||
- | |||
- | As you will note, the only remaining potential conversions are between long, double, and string. All other types have been made 100% strict (from/to native type only) | ||
- | |||
- | This ruleset is a pure restriction of the cases supported by the previous ruleset. | ||
- | This means that every conversion that succeeds with the new ruleset produces exactly | ||
- | the same result as it would have with the previous ruleset. | ||
- | |||
- | Example: String to numeric conversion is less permissive as we don't support non-blank trailing | ||
- | chars anymore. So, it will fail more often. But, when it succeeds, | ||
- | it produces exactly the same value as it would have in PHP 5. | ||
- | |||
- | ==== Other changes ==== | ||
- | |||
- | ==== Implement a PHP 5 optional compatibility layer ==== | ||
- | |||
- | TODO | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 142: | Line 124: | ||
==== php.ini Defaults ==== | ==== php.ini Defaults ==== | ||
- | |||
- | < | ||
- | newly-introduced errors to be raised as E_DEPRECATED instead of E_RECOVERABLE_ERROR. | ||
- | |||
- | Default value: Off | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
Line 154: | Line 131: | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
- | String to numeric conversion can be made smarter | + | String to numeric conversion can be improved |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== |
rfc/zpp-conversion-rules.1424478159.txt.gz · Last modified: 2017/09/22 13:28 (external edit)