Re: Return Type Hinting for Methods RFC

From: Date: Thu, 22 Dec 2011 22:55:38 +0000
Subject: Re: Return Type Hinting for Methods RFC
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-57036@lists.php.net to get a copy of this message
Your examples only show class methods with visibility qualifyiers, and looking at the changes to zend_language_parser.y it seems as if would only be available for methods. Wouldn't return hints be available for plain functions? In functional programming, it is common to return nullable types: returns an instance of class Foo or null, an array or false, etc. This is supported in normal arguments with the "= null" hint, and I think there should be something equivalent for return types. Does the proposed implementation allow null everywhere? (there's an example of returning null from a return hint of array) That seems wrong to me. Unless there's a way to make it strict (eg. array! for only arrays).

« previous php.internals (#57036) next »