3 ms·
Even if you have a point it wouldn't matter because making void functions return something else than null would be a big (useless) BC break. There's a lot of c
by spdionis 10y ago
Even if you have a point it wouldn't matter because making void functions return something else than null would be a big (useless) BC break.
There's a lot of code that uses "return;" to mean "return null;" and honestly I don't see it as a big problem.
- arenaninja 10y agoThe point I was trying to make is that PHP does not have -- nor should it have, I think -- a concept of void. Functions without a return statement already return null. "return;" is already equivalent to "return null;" as well, as you pointed out. It would be more consistent to type-hint return null instead of introducing a new return type (void) into the language. I know PHPDoc already uses "@return void", and I have never liked it for the same reason. It is not a concept used anywhere else in PHP, AFAIK.
- wtetzner 10y agoI think having a void return type makes a lot of sense, because it says "this function will never return anything but null".