rfc:scalar_type_hinting_with_cast

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:scalar_type_hinting_with_cast [2014/07/25 18:58] – Disallow booleans, v0.1.9 ajfrfc:scalar_type_hinting_with_cast [2021/09/09 06:07] (current) – Fixed a typo in the First Published at URL heiglandreas
Line 1: Line 1:
 ====== Request for Comments: Scalar Type Hinting With Casts ====== ====== Request for Comments: Scalar Type Hinting With Casts ======
-  * Version: 0.1.9 +  * Version: 0.1.9.1 
-  * Date: 2012-07-03 (reopened 2014-07-13, latest update 2014-07-20)+  * Date: 2012-07-03 (reopened 2014-07-13, latest update 2014-09-14, withdrawn 2014-09-15)
   * Author: Anthony Ferrara <ircmaxell@php.net> (original)   * Author: Anthony Ferrara <ircmaxell@php.net> (original)
   * Contributors: Andrea Faulds <ajf@ajf.me> (current maintainer)   * Contributors: Andrea Faulds <ajf@ajf.me> (current maintainer)
-  * Status: Under Discussion (previously Withdrawn) +  * Status: Withdrawn (previously Withdrawn then reopened
-  * First Published at: http://wiki.php.net/rfc/scalar_type_hinting_with_casts+  * First Published at: http://wiki.php.net/rfc/scalar_type_hinting_with_cast
  
 ===== Introduction ===== ===== Introduction =====
Line 41: Line 41:
   * //int// - Matching integers only   * //int// - Matching integers only
   * //float// - Matching floating point numbers   * //float// - Matching floating point numbers
-  * //numeric// - Mathing integers and floating point numbers (to allow polymorphic functions dealing with numbers)+  * //numeric// - Matching integers and floating point numbers (to allow polymorphic functions dealing with numbers)
   * //bool// - Matching boolean parameters only   * //bool// - Matching boolean parameters only
   * //string// - Matching strings only   * //string// - Matching strings only
Line 54: Line 54:
  
 ^ value                   ^ string ^ float  ^ int    ^ numeric ^ boolean‡^ array ^ ^ value                   ^ string ^ float  ^ int    ^ numeric ^ boolean‡^ array ^
-^ true (boolean)          | fail   | fail   | fail   | fail    | fail    | fail  | +^ true (boolean)          | fail   | fail   | fail   | fail    | pass    | fail  | 
-^ false (boolean)         | fail   | fail   | fail   | fail    | fail    | fail  |+^ false (boolean)         | fail   | fail   | fail   | fail    | pass    | fail  |
 ^ NULL (NULL)             | fail   | fail   | fail   | fail    | fail    | fail  | ^ NULL (NULL)             | fail   | fail   | fail   | fail    | fail    | fail  |
 ^ 0 (integer)             | pass   | pass   | pass   | pass    | fail    | fail  | ^ 0 (integer)             | pass   | pass   | pass   | pass    | fail    | fail  |
Line 125: Line 125:
 ==== Patch ==== ==== Patch ====
  
-The modifications necessary to implement this feature exist on the [[https://github.com/TazeTSchnitzel/php-src/tree/scalar_type_hints|scalar_type_hints branch of Andrea's GitHub fork]] (forked from the [[https://github.com/ircmaxell/php-src/tree/scalar_type_hints|branch on ircmaxell's GitHub fork]]). It is still a work-in-progress, and should be considered unstable at this time.+The modifications necessary to implement this feature exist on the [[https://github.com/TazeTSchnitzel/php-src/tree/scalar_type_hints|scalar_type_hints branch of Andrea's GitHub fork]] (forked from the [[https://github.com/ircmaxell/php-src/tree/scalar_type_hints|branch on ircmaxell's GitHub fork]]). It is stable to the best of Andrea's knowledgewith its tests passing and it breaking no known tests on her machine nor Travis.
  
 ===== Possible Changes ===== ===== Possible Changes =====
 +
 +For points I'm unsure on, this section lists possible future changes to the RFC.
  
 ==== Float to Int Casting Rules ==== ==== Float to Int Casting Rules ====
Line 178: Line 180:
 foo("1a"); // E_RECOVERABLE_ERROR foo("1a"); // E_RECOVERABLE_ERROR
 foo("a"); // E_RECOVERABLE_ERROR foo("a"); // E_RECOVERABLE_ERROR
 +foo(""); // E_RECOVERABLE_ERROR
 foo(999999999999999999999999999999999999); // E_RECOVERABLE_ERROR (since it's not exactly representable by an int) foo(999999999999999999999999999999999999); // E_RECOVERABLE_ERROR (since it's not exactly representable by an int)
 foo('999999999999999999999999999999999999'); // E_RECOVERABLE_ERROR (since it's not exactly representable by an int) foo('999999999999999999999999999999999999'); // E_RECOVERABLE_ERROR (since it's not exactly representable by an int)
Line 198: Line 201:
 foo("1a"); // E_RECOVERABLE_ERROR foo("1a"); // E_RECOVERABLE_ERROR
 foo("a"); // E_RECOVERABLE_ERROR foo("a"); // E_RECOVERABLE_ERROR
 +foo(""); // E_RECOVERABLE_ERROR
 foo(1.5); // float(1.5) foo(1.5); // float(1.5)
 foo(array()); // E_RECOVERABLE_ERROR foo(array()); // E_RECOVERABLE_ERROR
Line 216: Line 220:
 foo("1a"); // E_RECOVERABLE_ERROR foo("1a"); // E_RECOVERABLE_ERROR
 foo("a"); // E_RECOVERABLE_ERROR foo("a"); // E_RECOVERABLE_ERROR
 +foo(""); // E_RECOVERABLE_ERROR
 foo(1.5); // float(1.5) foo(1.5); // float(1.5)
 foo(array()); // E_RECOVERABLE_ERROR foo(array()); // E_RECOVERABLE_ERROR
Line 234: Line 239:
 foo("1a"); // string "1a" foo("1a"); // string "1a"
 foo("a"); // string "a" foo("a"); // string "a"
 +foo(""); // string ""
 foo(1.5); // string "1.5" foo(1.5); // string "1.5"
 foo(array()); // E_RECOVERABLE_ERROR foo(array()); // E_RECOVERABLE_ERROR
Line 254: Line 260:
 foo("1a"); // E_RECOVERABLE_ERROR foo("1a"); // E_RECOVERABLE_ERROR
 foo("a"); // E_RECOVERABLE_ERROR foo("a"); // E_RECOVERABLE_ERROR
 +foo(""); // E_RECOVERABLE_ERROR
 foo(1.5); // E_RECOVERABLE_ERROR foo(1.5); // E_RECOVERABLE_ERROR
 foo(array()); // E_RECOVERABLE_ERROR foo(array()); // E_RECOVERABLE_ERROR
Line 262: Line 269:
 ?> ?>
 </file> </file>
 +
 +===== Proposed Voting Choices =====
 +
 +As this is a language change, a 2/3 majority is required. Voting started 2014-09-14 and ends 2014-09-21.
 +
 +It will be a straight Yes/No vote.
  
 ===== More Information ===== ===== More Information =====
Line 285: Line 298:
   * 0.1.8.1 - Overflow prevention for int hints   * 0.1.8.1 - Overflow prevention for int hints
   * 0.1.9 - Booleans not accepted for int, float, numeric or string   * 0.1.9 - Booleans not accepted for int, float, numeric or string
 +  * 0.1.9.1 - Added "" to tests, patch is stable
rfc/scalar_type_hinting_with_cast.1406314700.txt.gz · Last modified: 2017/09/22 13:28 (external edit)