Re: [RFC] Return type-hint
| From: | Alain Williams | Date: | Thu, 28 Apr 2011 16:48:47 +0000 |
| Subject: | Re: [RFC] Return type-hint | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52061@lists.php.net to get a copy of this message | ||
On Fri, Apr 29, 2011 at 02:38:31AM +1000, Ben Schmidt wrote:
> I also see the value of such type checking for such a use case, obviously.
>
> I guess there's a reason for it after all.
>
> I'd still like to see something neat to handle more than just named
> classes, though, e.g. scalars, and things like "false on error" for return
> values.
That is why I suggested, in addition to the above, a syntax like:
function (Foo | NULL) foo($something) {
to be able to specify where a function can return more than one type.
The 'extra' types/values are nearly always either NULL or FALSE.
I agree that being able to specify as types: array, scalar, int, string, ...
would be useful for a compiler but prob have little value for Zend - other than
documentation/reflection.
--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>