rfc:returntypehint
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:returntypehint [2010/07/28 19:25] – created felipe | rfc:returntypehint [2010/07/29 00:42] – - Update felipe | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Request for Comments: | + | ====== Request for Comments: |
* Version: 1.0 | * Version: 1.0 | ||
* Date: 2010-07-28 | * Date: 2010-07-28 | ||
Line 15: | Line 15: | ||
* The new proposal has a better error message, identifying where the function/ | * The new proposal has a better error message, identifying where the function/ | ||
* Added generic " | * Added generic " | ||
+ | * No needed strange syntax to solve parser conflicts | ||
===== Examples ===== | ===== Examples ===== | ||
+ | === Using " | ||
<code php> | <code php> | ||
<?php | <?php | ||
Line 32: | Line 34: | ||
called in ... on line 9 and returning in ... on line 4 | called in ... on line 9 and returning in ... on line 4 | ||
*/ | */ | ||
+ | </ | ||
+ | |||
+ | === Using an user class type === | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | class Bar { } | ||
+ | |||
+ | class Foo extends Bar { | ||
+ | public function Bar test($x) { | ||
+ | return $x; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $foo = new Foo; | ||
+ | $foo-> | ||
+ | $foo-> | ||
+ | /* | ||
+ | PHP Catchable fatal error: | ||
+ | called in ... on line 13 and returning in ... on line 7 | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | === Interface defining the return type-hint === | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | interface ITest { | ||
+ | function string bar(); | ||
+ | } | ||
+ | |||
+ | class Foo implements ITest { | ||
+ | public function int bar() { | ||
+ | } | ||
+ | } | ||
+ | // PHP Fatal error: | ||
+ | </ | ||
+ | |||
+ | === Using a namespaced class === | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | namespace foo { | ||
+ | class foo { } | ||
+ | class bar extends foo { } | ||
+ | } | ||
+ | |||
+ | namespace bar { | ||
+ | class bar { | ||
+ | public function \foo\foo test() { | ||
+ | return new \foo\bar; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $bar = new bar; | ||
+ | $bar-> | ||
+ | } | ||
</ | </ | ||
Line 38: | Line 100: | ||
* See below some information that will be possible to be get using Reflection. | * See below some information that will be possible to be get using Reflection. | ||
- | - Using a class type. | + | === Using a class type === |
<code php> | <code php> | ||
Line 56: | Line 118: | ||
var_dump($func-> | var_dump($func-> | ||
var_dump($func-> | var_dump($func-> | ||
- | var_dump($func-> | + | var_dump($func-> |
</ | </ | ||
- | - PHP native types | + | === PHP native types === |
<code php> | <code php> | ||
Line 75: | Line 137: | ||
===== Patch ===== | ===== Patch ===== | ||
- | Comming soon | + | * Engine + Reflection: http:// |
+ | * Tests: http:// |
rfc/returntypehint.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1