I was testing return types with PHP 7.
I\'ve created a simple script to test return types of PHP 7:
The void
return type was accepted for php 7.1. So it will come in the future.
Some examples on how it will work:
function should_return_nothing(): void {
return 1; // Fatal error: A void function must not return a value
}
function returns_null(): void {
return null; // Fatal error: A void function must not return a value
}
function lacks_return(): void {
// valid
}
function returns_nothing(): void {
return; // valid
}
See the RFC from Andrea Faulds for more info!