Edit:
A new separate RFC for a void return type has been published, has passed the vote, and was implemented in PHP 7.1.
There is now a void
return type in PHP. 🙂
Original Post:
Taken from wiki.php.net:
Future Work
Ideas for future work which are out of the scope of this RFC include:
- Allow functions to declare that they do not return anything at all (void in Java and C)
So currently there is no way to declare that you don’t return anything.
I don’t know what’s best in your situation, but I’d probably just go with not declaring the return type for now.
To answer your question whether there will be a void
return type in PHP 7:
There is no guarantee yet, but I think it is very likely that void
or a synonym will be implemented in some way.