A void %s must not return a value

Description

A function, method or closure that uses the void return type, must not have a return expression with a parameter, in its body.

This is checked anywhere in the body of the function, at compilation time.

It is possible to use return, without any argument. It is not possible to return null, it must be without argument.

Example

<?php

function foo() : void {
    return 1;
}

?>

Solutions

  • Remove the return expression.

  • Remove the argument of the return expression.

  • Remove the void returntype.