Re: [RFC] Return type-hint
| From: | Alain Williams | Date: | Thu, 28 Apr 2011 13:39:15 +0000 |
| Subject: | Re: [RFC] Return type-hint | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52057@lists.php.net to get a copy of this message | ||
On Thu, Apr 28, 2011 at 10:30:43AM -0300, Martin Scotta wrote:
> Hey All,
> I'm really interested on this topic.
>
> What would be the result of this?
>
> function Foo foo($something) {
> if ( $something ) {
> return new Foo;
> }
> // no return implies return null
> }
>
> How do you force to return a Type with null allowed?
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.
Regards
--
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>