rfc:returntypehint

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:returntypehint [2010/07/28 19:38] – change the title feliperfc:returntypehint [2010/07/28 20:08] – New exampel felipe
Line 33: Line 33:
 PHP Catchable fatal error:  The returned value must be of the type scalar, PHP Catchable fatal error:  The returned value must be of the type scalar,
 called in ... on line 9 and returning in ... on line 4 called in ... on line 9 and returning in ... on line 4
 +*/
 +</code>
 +
 +=== 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->test($foo);         // ok
 +$foo->test(new stdClass); // fail
 +/*
 +PHP Catchable fatal error:  The returned value should be instance of Bar,
 +called in ... on line 13 and returning in ... on line 7
 */ */
 </code> </code>
Line 74: Line 96:
 var_dump($func->getReturnType()); // "Test" var_dump($func->getReturnType()); // "Test"
 var_dump($func->returnsObject()); // true var_dump($func->returnsObject()); // true
-var_dump($func->returnsClass());  // "Test"+var_dump($func->getReturnClass());  // "Test"
 </code> </code>
  
rfc/returntypehint.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1