rfc:returntypehint

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:returntypehint [2010/07/29 00:42]
felipe - Update
rfc:returntypehint [2017/09/22 13:28] (current)
Line 116: Line 116:
  
 $func = new ReflectionMethod('​foo::​test'​);​ $func = new ReflectionMethod('​foo::​test'​);​
-var_dump($func->​getReturnType()); // "​Test"​ +var_dump($func->​getReturnTypeHint());   ​// "​Test"​ 
-var_dump($func->​returnsObject());​ // true +var_dump($func->​returnsObject()); ​      ​// true
-var_dump($func->​getReturnClass()); ​ // "​Test"​+
 </​code>​ </​code>​
  
Line 131: Line 130:
  
 $func = new ReflectionFunction('​abc'​);​ $func = new ReflectionFunction('​abc'​);​
-var_dump($func->​getReturnType()); // scalar+var_dump($func->​getReturnTypeHint()); // scalar 
 +var_dump($func->​returnsScalar()); ​    // true
 </​code>​ </​code>​
  
 +=== Using "​self"​ as type ===
 +
 +<code php>
 +<?php
 +
 +class foo {
 + function self bar() {
 + return new foo;
 + }
 +}
 +
 +$func = new ReflectionMethod('​foo::​bar'​);​
 +var_dump($func->​getReturnTypeHint());​ // foo
 +var_dump($func->​returnsObject()); ​    // true
 +</​code>​
  
 ===== Patch ===== ===== Patch =====
rfc/returntypehint.1280364175.txt.gz · Last modified: 2017/09/22 13:28 (external edit)