rfc:typehint
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:typehint [2008/04/17 02:12] – Fix error messages. felipe | rfc:typehint [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2008-04-07 | * Date: 2008-04-07 | ||
* Author: Felipe Pena < | * Author: Felipe Pena < | ||
- | * Status: Under Discussion | + | * Status: |
====== Details of implementation ====== | ====== Details of implementation ====== | ||
**Parameter type hint:** | **Parameter type hint:** | ||
- | - The behavior when the default value is NULL was keeped. | + | - The behavior when the default |
**Both:** | **Both:** | ||
- Binary and unicode string are specified by '' | - Binary and unicode string are specified by '' | ||
Line 15: | Line 16: | ||
==== BC Break ==== | ==== BC Break ==== | ||
No BC break using the " | No BC break using the " | ||
+ | |||
==== Examples ==== | ==== Examples ==== | ||
Line 96: | Line 98: | ||
} | } | ||
- | test(' | + | test(' |
- | test(-1); | + | |
- | test(1); | + | |
- | test(1.); // Catchable fatal error: The returned value must be of the type integer | + | |
</ | </ | ||
Line 130: | Line 129: | ||
- isObject() | - isObject() | ||
- isResource() | - isResource() | ||
+ | |||
==== Examples ==== | ==== Examples ==== | ||
+ | |||
+ | === With default parameter value === | ||
+ | <code php> | ||
+ | function test(integer $value = ' | ||
+ | } | ||
+ | // Fatal error: Default value for parameters with integer type hint can only be the exact type or NULL | ||
+ | </ | ||
=== integer / int === | === integer / int === | ||
Line 140: | Line 147: | ||
test(1); | test(1); | ||
- | test(" | ||
test(-1); | test(-1); | ||
- | test(" | + | test(" |
- | + | // Catchable fatal error: Argument 1 passed to test() must be of the type integer, string given ... | |
- | function test(integer $value = ' | + | |
- | } | + | |
- | // Fatal error: Default value for parameters with integer type hint can only be the exact type or NULL | + | |
</ | </ | ||
Line 156: | Line 159: | ||
test(1.1); | test(1.1); | ||
test(.1); | test(.1); | ||
- | test(" | + | test(" |
- | test(" | + | |
- | + | ||
- | function test(double $value = ' | + | |
- | } | + | |
- | // Fatal error: Default value for parameters with double type hint can only be the exact type or NULL | + | |
</ | </ | ||
Line 170: | Line 168: | ||
test(false); | test(false); | ||
- | test(0); | + | test(0); // Catchable fatal error: Argument 1 passed to test() must be of the type boolean, null given |
- | test(1); | + | |
- | test(' | + | |
- | test(' | + | |
- | test('' | + | |
- | test(null); // Catchable fatal error: Argument 1 passed to test() must be of the type boolean, null given | + | |
</ | </ | ||
Line 194: | Line 187: | ||
test(new stdclass); | test(new stdclass); | ||
test(NULL); // Catchable fatal error: Argument 1 passed to test() must be of the type object, null given | test(NULL); // Catchable fatal error: Argument 1 passed to test() must be of the type object, null given | ||
- | |||
- | function test(object $value = 1) { | ||
- | } | ||
- | // Fatal error: Default value for parameters with object type hint can only be the exact type or NULL | ||
</ | </ | ||
- | ===== Patches ===== | + | ===== Patches |
- | - Return value type hint: http:// | + | - Return value type hint: http:// |
- | - Parameter type hint: http:// | + | - Parameter type hint: http:// |
+ | - Tests: http:// | ||
rfc/typehint.1208398351.txt.gz · Last modified: 2017/09/22 13:28 (external edit)