Re: [RFC] Void Return Type (v0.2, reöpeni ng)
| From: | Levi Morrison | Date: | Wed, 14 Oct 2015 22:46:17 +0000 |
| Subject: | Re: [RFC] Void Return Type (v0.2, reöpeni ng) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88796@lists.php.net to get a copy of this message | ||
On Wed, Oct 14, 2015 at 4:00 PM, Stanislav Malyshev <smalyshev@gmail.com> wrote:
> Hi!
>
>> I'm reviving my Void Return Type RFC, this time for PHP 7.1:
>>
>> https://wiki.php.net/rfc/void_return_type
>>
>> Please read it and tell me your thoughts!
>
> I still see no point in this, as every PHP function actually returns
> something (at least null). So this type would not actually be right and
> would not reflect what actually is happening.
I agree that
void doesn't make sense given that we document that
return; will return null[1]. If the union types RFC[2] passes it
makes sense to allow Foo | null which allows something of type Foo
or null. To me it makes sense that if you then remove Foo you are
left with null, not void. My personal recommendation because of
this would be to use null for the return type and instead of void.
Also, I do not think this feature is pointless. For instance, it has
value in interfaces. Declaring that a method does not return a value
means implementors cannot accidentally return something. This is
better than just documenting that it should not be done.
[1]: http://php.net/manual/en/function.return.php
[2]: https://wiki.php.net/rfc/union_types