Codeception: A void function must not return a value error since 4.1.2

Created on 16 Mar 2020  路  4Comments  路  Source: Codeception/Codeception

Caused by #5862

What are you trying to achieve?

Return types on generated actions for methods that return void should not use return since you cannot return a void:

public function voidMethod(): void {
    $this->getScenario()->runStep(new \Codeception\Step\Action('voidMethod', func_get_args()));
}

What do you get instead?

public function voidMethod(): void {
    return $this->getScenario()->runStep(new \Codeception\Step\Action('voidMethod', func_get_args()));
}

This causes PHP errors:

Fatal error:  A void function must not return a value

Details

  • Codeception version: 4.1.2
  • PHP Version: 7.3.15
  • Operating System: Ubuntu 18.04.3
  • Installation type: Composer

Most helpful comment

Yeah @Naktibalda. codecept build always runs successfully but running tests crashes with the fatal error in 4.1.3 but doesn't crash after applying patch from #5880

All 4 comments

Upgrading my project to 4.1.3 still has this problem. This needs reopening.

Upgrading my project to 4.1.3 still has this problem. This needs reopening.

Can confirm, still getting "A void function must not return a value in /var/www/html/tests/_support/_generated/ApiTesterActions.php line 5361"

Have you ran codecept build after upgrade?

Yeah @Naktibalda. codecept build always runs successfully but running tests crashes with the fatal error in 4.1.3 but doesn't crash after applying patch from #5880

Was this page helpful?
0 / 5 - 0 ratings