Also, it helps prevent the abuse of interfaces. I can say "this method does not return values" and enforce it. That can be useful on a big project, with junior devs.
PHP's built-in functions documented as "void" also return NULL, so I suppose there's an argument from consistency.
> Choosing one over the other suggests intent. If you specify a value, it suggests the value is significant. In a void function, the return value is insignificant: it's always the same and has no actual usefulness. https://wiki.php.net/rfc/void_return_type#why_isn_t_return_n...
I guess this 'pragmatism over consistency' fits in with the general ethos of PHP. I guess it's why so many people hate it, but I can't imagine a situation in which this will actually cause a problem.
There's a lot of code that uses "return;" to mean "return null;" and honestly I don't see it as a big problem.
https://github.com/facebook/hhvm/blob/HHVM-3.13/hphp/hack/te...
... has an obvious code smell detectable statically:
https://github.com/facebook/hhvm/blob/HHVM-3.13/hphp/hack/te...