rfc:scalar_type_hinting_with_cast
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:scalar_type_hinting_with_cast [2014/07/25 01:13] – Overflow prevention for int hints ajf | rfc:scalar_type_hinting_with_cast [2014/09/15 13:06] – Withdrew RFC ajf | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Request for Comments: Scalar Type Hinting With Casts ====== | ====== Request for Comments: Scalar Type Hinting With Casts ====== | ||
- | * Version: 0.1.8.1 | + | * 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 < | * Author: Anthony Ferrara < | ||
* Contributors: | * Contributors: | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 15: | Line 15: | ||
This RFC discusses a method of adding scalar type hints to PHP while attempting to embrace the dynamic nature of PHP variables. | This RFC discusses a method of adding scalar type hints to PHP while attempting to embrace the dynamic nature of PHP variables. | ||
- | For consistency, | + | For consistency, |
=== Rationale for this proposal compared to others === | === Rationale for this proposal compared to others === | ||
Line 41: | Line 41: | ||
* //int// - Matching integers only | * //int// - Matching integers only | ||
* //float// - Matching floating point numbers | * //float// - Matching floating point numbers | ||
- | * //numeric// - Mathing | + | * //numeric// - Matching |
* //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) | + | ^ true (boolean) |
- | ^ false (boolean) | + | ^ false (boolean) |
+ | ^ NULL (NULL) | ||
^ 0 (integer) | ^ 0 (integer) | ||
^ 1 (integer) | ^ 1 (integer) | ||
Line 72: | Line 73: | ||
^ array () (array) | ^ array () (array) | ||
^ array (0 => 12) (array) | fail | fail | fail | fail | fail | pass | | ^ array (0 => 12) (array) | fail | fail | fail | fail | fail | pass | | ||
- | ^ NULL (NULL) | ||
^ %%'' | ^ %%'' | ||
^ 1 (resource) | ^ 1 (resource) | ||
Line 125: | Line 125: | ||
==== Patch ==== | ==== Patch ==== | ||
- | The modifications necessary to implement this feature exist on the [[https:// | + | The modifications necessary to implement this feature exist on the [[https:// |
===== 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(" | foo(" | ||
foo(" | foo(" | ||
+ | foo("" | ||
foo(999999999999999999999999999999999999); | foo(999999999999999999999999999999999999); | ||
foo(' | foo(' | ||
Line 198: | Line 201: | ||
foo(" | foo(" | ||
foo(" | foo(" | ||
+ | foo("" | ||
foo(1.5); // float(1.5) | foo(1.5); // float(1.5) | ||
foo(array()); | foo(array()); | ||
Line 216: | Line 220: | ||
foo(" | foo(" | ||
foo(" | foo(" | ||
+ | foo("" | ||
foo(1.5); // float(1.5) | foo(1.5); // float(1.5) | ||
foo(array()); | foo(array()); | ||
Line 234: | Line 239: | ||
foo(" | foo(" | ||
foo(" | foo(" | ||
+ | foo("" | ||
foo(1.5); // string " | foo(1.5); // string " | ||
foo(array()); | foo(array()); | ||
Line 254: | Line 260: | ||
foo(" | foo(" | ||
foo(" | foo(" | ||
+ | foo("" | ||
foo(1.5); // E_RECOVERABLE_ERROR | foo(1.5); // E_RECOVERABLE_ERROR | ||
foo(array()); | foo(array()); | ||
Line 262: | Line 269: | ||
?> | ?> | ||
</ | </ | ||
+ | |||
+ | ===== 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 284: | Line 297: | ||
* 0.1.8 - Added numeric typehint | * 0.1.8 - Added numeric typehint | ||
* 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.1 - Added "" |
rfc/scalar_type_hinting_with_cast.txt · Last modified: 2021/09/09 06:07 by heiglandreas