rfc:parameter_type_casting_hints
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:parameter_type_casting_hints [2012/03/04 01:27] – [Cast Type Definitions] ircmaxell | rfc:parameter_type_casting_hints [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2012-03-03 | * Date: 2012-03-03 | ||
* Author: Anthony Ferrara < | * Author: Anthony Ferrara < | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
* Patch: https:// | * Patch: https:// | ||
Line 14: | Line 14: | ||
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. | ||
+ | |||
+ | It's worth noting that this RFC does not attempt to add new errors to the casting paradigm in PHP. It's my feeling that issuing errors (E_NOTICE or E_STRICT) on data-loss from cast operations is important, but a more general issue to PHP. So as such it does not fall under this specific RFC, but as a more general RFC which can be added to the language as a whole. | ||
+ | |||
+ | So in an attempt at consistency, | ||
===== Implementation ===== | ===== Implementation ===== | ||
Line 23: | Line 27: | ||
<?php | <?php | ||
- | function test((int) $intParam, (string) $strParam = " | + | function test((int) $intParam, (string) $strParam = " |
?> | ?> | ||
Line 51: | Line 55: | ||
Note that the final 2 options (array and object) are there for both completeness, | Note that the final 2 options (array and object) are there for both completeness, | ||
+ | |||
+ | ==== Default Values ==== | ||
+ | |||
+ | For consistency, | ||
+ | |||
+ | If '' | ||
+ | |||
+ | function test1((int) $foo) { echo gettype($foo); | ||
+ | function test2((int) $foo = null) { echo gettype($foo); | ||
+ | | ||
+ | Calling '' | ||
==== Backwards compatibility breaks ==== | ==== Backwards compatibility breaks ==== | ||
Line 80: | Line 95: | ||
To prevent odd behavior, it is a '' | To prevent odd behavior, it is a '' | ||
- | |||
- | ==== Default Values ==== | ||
- | |||
- | For consistency, | ||
==== Parser Tokens ==== | ==== Parser Tokens ==== | ||
Line 90: | Line 101: | ||
===== Changelog ===== | ===== Changelog ===== | ||
- |
rfc/parameter_type_casting_hints.1330824453.txt.gz · Last modified: 2017/09/22 13:28 (external edit)