rfc:implicit-float-int-deprecate

Differences

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

Link to this comparison view

Next revision
Previous revision
rfc:implicit-float-int-deprecate [2021/03/04 12:54] – Creation girgiasrfc:implicit-float-int-deprecate [2021/05/31 14:49] (current) – Mark as implemented girgias
Line 3: Line 3:
   * Date: 2021-02-03   * Date: 2021-02-03
   * Author: George Peter Banyard, <girgias@php.net>   * Author: George Peter Banyard, <girgias@php.net>
-  * Status: Under discussion+  * Status: Implemented (https://github.com/php/php-src/commit/b6958bb8476306c2f6ce110782330c41e6a5df3a) 
 +  * Discussion: https://externals.io/message/113371
   * First Published at: http://wiki.php.net/rfc/implicit-float-int-deprecate   * First Published at: http://wiki.php.net/rfc/implicit-float-int-deprecate
   * GitHub mirror: https://github.com/Girgias/float-int-warning   * GitHub mirror: https://github.com/Girgias/float-int-warning
Line 26: Line 27:
  
 If the conversion happens from a ''float'' the diagnostic message is: If the conversion happens from a ''float'' the diagnostic message is:
-> Implicit conversion to int from non-compatible float+> Implicit conversion to int from non-compatible float %f
  
 If the conversion happens from a ''float''-string the diagnostic message is: If the conversion happens from a ''float''-string the diagnostic message is:
-> Implicit conversion to int from non-compatible float-string+> Implicit conversion to int from non-compatible float-string %s
  
-Raise these warnings to ''TypeError'' in the next major version (PHP 9.0).+Where ''%f'' and ''%s'' correspond to the value of the float/float-string value which is not integer-compatible. 
 + 
 +Raise these deprecation diagnostics to ''TypeError'' in the next major version (PHP 9.0).
  
 ===== Rationale ===== ===== Rationale =====
Line 39: Line 42:
  
 The lack of possibility of knowing if data loss arises necessitates the use of the ''strict_type'' mode, which is an issue in itself when using a function which returns a ''float'' but given the input arguments The lack of possibility of knowing if data loss arises necessitates the use of the ''strict_type'' mode, which is an issue in itself when using a function which returns a ''float'' but given the input arguments
-an ''int'' compatible return is to be expected, this mostly affects mathematical functions, the most notable example being the ''round()'' function when passing a non-positive precision+an ''int'' compatible return is to be expected, this mostly affects mathematical functions, the most notable example being the <php>round()</php> function when passing a non-positive precision.
  
 The use of a ''float'' or float string as a string offset already emits a warning as it needs The use of a ''float'' or float string as a string offset already emits a warning as it needs
 to perform a conversion, this proposal would generalize this aspect to other areas of PHP. to perform a conversion, this proposal would generalize this aspect to other areas of PHP.
  
-Finally, attempting to pass a ''float'' or float string which exceeds the range representable by an ''int'' already causes a ''TypeError'' to be thrown.+Finally, attempting to pass a ''float'' or float string which exceeds the range representable by an ''int'' as an argument to parameter with an ''int'' type declaration already causes a <php>TypeError</php> to be thrown, regardless of typing mode.
  
 ===== Implementation notes ===== ===== Implementation notes =====
Line 103: Line 106:
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
 As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted.
 +
 +<doodle title="Accept Deprecate implicit non-integer-compatible float to int conversions RFC proposal" auth="girgias" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
Line 108: Line 116:
  
 ===== Implementation ===== ===== Implementation =====
-After the project is implemented, this section should contain +Implemented in https://github.com/php/php-src/commit/b6958bb8476306c2f6ce110782330c41e6a5df3a
-  the version(s) it was merged into +
-  - a link to the git commit(s) +
-  - a link to the PHP manual entry for the feature +
-  - a link to the language specification section (if any) +
 ===== References ===== ===== References =====
  
 +Initial mailing list discussion: <https://externals.io/message/113077> \\
 +Revised mailing list discussion: <https://externals.io/message/113371> \\
rfc/implicit-float-int-deprecate.1614862441.txt.gz · Last modified: 2021/03/04 12:54 by girgias