rfc:invalid_strings_in_arithmetic

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
rfc:invalid_strings_in_arithmetic [2016/02/14 02:19] – v1.1.3 opcache compat ajfrfc:invalid_strings_in_arithmetic [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 3: Line 3:
   * Date: 2016-01-08   * Date: 2016-01-08
   * Author: Andrea Faulds, ajf@ajf.me   * Author: Andrea Faulds, ajf@ajf.me
-  * Status: Under Discussion+  * Status: Implemented (PHP 7.1)
   * First Published at: http://wiki.php.net/rfc/invalid_strings_in_arithmetic   * First Published at: http://wiki.php.net/rfc/invalid_strings_in_arithmetic
  
Line 68: Line 68:
 This inconsistency is unintuitive, and becomes a greater problem if we add warnings and notices for non-numeric strings, as some operators would tell you strings like ''"1.2345e9"'' and ''"-123.45"'' are non-well-formed, whereas other operators would happily accept such strings. This inconsistency is unintuitive, and becomes a greater problem if we add warnings and notices for non-numeric strings, as some operators would tell you strings like ''"1.2345e9"'' and ''"-123.45"'' are non-well-formed, whereas other operators would happily accept such strings.
  
-To avoid this problem, this RFC proposes use ''is_numeric_string_ex'' instead of ''strtol'' for the integer operators and integer casts (<php>intval()</php> with <php>$base</php> = 10, <php>(int)</php>, <php>settype()</php>, etc.), resolving the inconsistency. This also affects the Zend Engine C functions ''zval_get_long'' and ''convert_to_long'', and so PHP functions which uses these internal functions are also affected, including <php>decbin()</php>, <php>decoct()</php> and <php>dechex()</php>.+To avoid this problem, this RFC proposes to use ''is_numeric_string_ex'' instead of ''strtol'' for the integer operators and integer casts (<php>intval()</php> with <php>$base</php> = 10, <php>(int)</php>, <php>settype()</php>, etc.), resolving the inconsistency. This also affects the Zend Engine C functions ''zval_get_long'' and ''convert_to_long'', and so PHP functions which uses these internal functions are also affected, including <php>decbin()</php>, <php>decoct()</php> and <php>dechex()</php>.
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 100: Line 100:
 ==== To Opcache ==== ==== To Opcache ====
  
-I have thoroughly the RFC against opcache, and patching three different Zend Optimizer optimisations which created problems. At the time of writing this, all tests now pass both with Opcache enabled and Opcache disabled.+I have tested the RFC against opcache, and patched three different Zend Optimizer optimisations which created problems. At the time of writing this, all tests now pass both with Opcache enabled and Opcache disabled.
  
 ==== To Constants === ==== To Constants ===
Line 130: Line 130:
 As this is a language change, the RFC requires a 2/3 majority to pass. As this is a language change, the RFC requires a 2/3 majority to pass.
  
-Voting started on 2016-01-23 and was scheduled to end on 2016-01-31, but was cancelled due to the issue of float handling (see //Fractional and scientific notation strings with integer operators//, added in v1.1).+Voting started on 2016-03-20 and ended on 2016-03-28.
  
-<doodle title="Warn about invalid strings in arithmetic" auth="ajf" voteType="single" closed="true">+<doodle title="Accept the ‘Warn about invalid strings in arithmetic’ v1.1 RFC for PHP 7.1?" auth="ajf" voteType="single" closed="true">
    * Yes    * Yes
    * No    * No
 </doodle> </doodle>
 +
 +[[https://wiki.php.net/rfc/invalid_strings_in_arithmetic?rev=1453841945|Voting had previously opened on 2016-01-23]], but it was cancelled due to the //Fractional and scientific notation strings with integer operators// issue.
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
-An incomplete pull request can be found here: https://github.com/php/php-src/pull/1718+A complete pull request for the PHP interpreter, including tests, can be found here: https://github.com/php/php-src/pull/1718
  
-There is not yet a patch for the language specification.+A complete pull request for the PHP language specification, including tests, can be found here: https://github.com/php/php-langspec/pull/155
  
 ===== Implementation ===== ===== Implementation =====
-After the project is implemented, this section should contain  + 
-  - the version(s) it was merged to +The interpreter patch was merged into 7.1 here: https://github.com/php/php-src/commit/1e82ad8038d3100b7e27be870652c1f639a7200a 
-  a link to the git commit(s) + 
-  a link to the PHP manual entry for the feature+The UPGRADING file notes can be found here (more extensive than in the previously-linked patch), see sections 1 and 2: https://github.com/php/php-src/blob/0105bd20b706c8ab5b0a71f59f11a9dabe735f6b/UPGRADING 
 + 
 +The corresponding mention in the manual can be found here: http://php.net/manual/en/migration71.other-changes.php 
 + 
 +The language specification patch was merged into 7.1 here: https://github.com/php/php-langspec/commit/a3ea4e992f43ea9083c3fe3738a5ded03412f6e1
  
 ===== References ===== ===== References =====
rfc/invalid_strings_in_arithmetic.1455416377.txt.gz · Last modified: 2017/09/22 13:28 (external edit)