Fix PHPStan L2 error "Function foo() should return Bar but return statement is missing."

Created on 3 December 2022, over 2 years ago
Updated 13 November 2023, over 1 year ago

Problem/Motivation

Amongst the "new" errors found when running PHPStan on level 2 is: Function foo() should return Bar but return statement is missing.

This child-issue exists to fix all of those.

Steps to reproduce

- Run PHPStan on level 2 and see the above error amongst all others.

Proposed resolution

- Solve all of the the above mentioned reported errors.
- Run PHPStan on level 2 and don't see the above mentioned error any more.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Javascript 

Last updated 4 days ago

Created by

🇳🇱Netherlands spokje

Live updates comments and jobs are added and updated live.
  • Needs framework manager review

    It is used to alert the framework manager core committer(s) that an issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy draft for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

  • Needs release manager review

    It is used to alert the release manager core committer(s) that an issue significantly affects the overall technical debt or release timeline of Drupal, and their signoff is needed. See the governance policy draft for more information.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia mstrelan

    I don't think we should be using @return foo|void. If we want to add a native return type later this is invalid, it has to either return something or not.

    For _batch_next_set it's called by _batch_process which treats the return as a bool, so for that one I think we could just return FALSE.

    For batch_process the places that call it seem to check if the return value is a Response or not, so we should return NULL otherwise. Similar for _batch_queue, not sure why we wouldn't return NULL here.

    install_run_task should quite obviously return NULL and not void. It's called like this: $output = install_run_task($task, $install_state);. If we return void it just gets coerced to NULL anyway. Same for install_get_form which is called from install_run_task

    I'm happy to work on this if people agree with this point of view.

Production build 0.71.5 2024