rfc:return_types

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
Last revisionBoth sides next revision
rfc:return_types [2015/01/14 09:10] – Move status to Voting levimrfc:return_types [2015/02/27 23:11] – old revision restored (2015/01/30 15:38) levim
Line 4: Line 4:
   * Date: 2014-03-20    * Date: 2014-03-20 
   * Author: Levi Morrison <levim@php.net>   * Author: Levi Morrison <levim@php.net>
-  * Status: Voting+  * Status: Implemented (PHP 7.0)
   * First Published at: https://wiki.php.net/rfc/returntypehinting   * First Published at: https://wiki.php.net/rfc/returntypehinting
   * Migrated to: https://wiki.php.net/rfc/return_types   * Migrated to: https://wiki.php.net/rfc/return_types
Line 166: Line 166:
 get_config(); get_config();
 </PHP> </PHP>
-''Catchable fatal error: The function get_config was expected to return an array and returned an integer in %s on line %d''+''Catchable fatal error: Return value of get_config() must be of the type arrayinteger returned in %s on line %d''
  
 ---- ----
Line 178: Line 178:
 answer(); answer();
 </PHP> </PHP>
-''Catchable fatal error: The function answer was expected to return an object of class int and returned an integer in %s on line %d''+''Catchable fatal error: Return value of answer() must be an instance of intinteger returned in %s on line %d''
  
 ---- ----
Line 190: Line 190:
 foo(); foo();
 </PHP> </PHP>
-''Catchable fatal error: The function foo was expected to return an object of class DateTime and returned null in %s on line %d''+''Catchable fatal error: Return value of foo() must be an instance of DateTimenull returned in %s on line %d''
  
 ---- ----
Line 210: Line 210:
 } }
 </PHP> </PHP>
-''Fatal error: Declaration of UserGateway_MySql::find should be compatible with UserGateway::find($id): User, return type missing in %s on line %d''+''Fatal error: Declaration of UserGateway_MySql::find() must be compatible with UserGateway::find($id): User in %s on line %d''
  
 ---- ----
Line 227: Line 227:
 This proposal specifically does not allow declaring multiple return types; this is out of the scope of this RFC and would require a separate RFC if desired. This proposal specifically does not allow declaring multiple return types; this is out of the scope of this RFC and would require a separate RFC if desired.
  
-If you want to use multiple return types, simply omit a return type declaration and rely on PHP's excellent dynamic nature.+If you want to use multiple return types in the meantime, simply omit a return type declaration and rely on PHP's excellent dynamic nature.
  
 ==== Reflection ==== ==== Reflection ====
Line 262: Line 262:
 This RFC modifies the PHP language syntax and therefore requires a two-third majority of votes. This RFC modifies the PHP language syntax and therefore requires a two-third majority of votes.
  
-Should return types as outlined in this RFC be added to the PHP language? Voting will end on January 23, 2014+Should return types as outlined in this RFC be added to the PHP language? Voting will end on January 23, 2015
-<doodle title="Typed Returns" auth="levim" voteType="single" closed="false">+<doodle title="Typed Returns" auth="levim" voteType="single" closed="true">
    * Yes    * Yes
    * No    * No
Line 271: Line 271:
  
 Dmitry and I have updated the implementation to a more current master branch here: https://github.com/php/php-src/pull/997 Dmitry and I have updated the implementation to a more current master branch here: https://github.com/php/php-src/pull/997
 +
 +This RFC was merged into the master branch (PHP 7) in commit [[https://git.php.net/?p=php-src.git;a=commit;h=638d0cb7531525201e00577d5a77f1da3f84811e|638d0cb7531525201e00577d5a77f1da3f84811e]].
  
 ===== Future Work ===== ===== Future Work =====
rfc/return_types.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1