rfc:zpp-conversion-rules

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:zpp-conversion-rules [2015/02/21 00:21] francoisrfc:zpp-conversion-rules [2017/09/22 13:28] – external edit 127.0.0.1
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: Draft   * Status: Draft
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 convert input arguments to internal functions+
- +
-Then, minor additions to be used by the userland type hinting system are proposed.+
  
 ===== History ===== ===== History =====
Line 69: Line 65:
  
   * Disable IS_FALSE/IS_NULL to anything except bool.   * Disable IS_FALSE/IS_NULL to anything except bool.
-  * Disable any conversion to bool except from IS_FALSE/IS_TRUE.+  * IS_STRING to bool: Convert every string that would be converted to 0 or 0.0 to false, instead of just “0”.
   * Disable IS_NULL to be accepted for any ZPP type except the new 'null'.   * Disable IS_NULL to be accepted for any ZPP type except the new 'null'.
   * 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  ^ IS_FALSE ^ IS_TRUE  ^ IS_LONG   ^ IS_DOUBLE ^  IS_STRING ^ ^  ZPP type     ^ IS_NULL  ^ IS_FALSE ^ IS_TRUE  ^ IS_LONG   ^ IS_DOUBLE ^  IS_STRING ^
-^ null          | <native> |  -       | -        | -                         +^ null          | <native> |  -       | -        | -                | -         
-^ bool          |  -       | <native> | <native>-         |  -         |  -        +^ bool          |  -       | <native> | <native>Yes (1)   |  Yes (1)  |  Yes (5)  
-^ long          |  -        -        -       | <native>  |  (1      |  (2)      | +^ long          |  -        -        -       | <native>  |  (2     |  (3)      | 
-^ double        |  -        -        -       | Yes       | <native>   |  (3)      | +^ double        |  -        -        -       | Yes       | <native>  |  (4)      | 
-^ string        |  -        -        -       | Yes        Yes       | <native>  |+^ string        |  -        -        -       | Yes        Yes      | <native>  |
  
-  * (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 144: Line 124:
  
 ==== php.ini Defaults ==== ==== php.ini Defaults ====
- 
-<name-to-define> : Enables PHP 5 compatibility mode. When turned on, causes 
-newly-introduced errors to be raised as E_DEPRECATED instead of E_RECOVERABLE_ERROR. 
- 
-Default value: Off 
  
 ===== Open Issues ===== ===== Open Issues =====
Line 156: Line 131:
 ===== Future Scope ===== ===== Future Scope =====
  
-String to numeric conversion can be made smarter and accept a richer syntax.+String to numeric conversion can be improved and accept a richer syntax.
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
rfc/zpp-conversion-rules.txt · Last modified: 2021/03/27 14:25 by ilutov