Make WordPress Core


Ignore:
Timestamp:
08/27/2026 10:33:18 PM (4 days ago)
Author:
westonruter
Message:

Code Quality: Add the documented return null; to 14 functions.

PHPStan reports return.missing where a documented return type obliges a function to return a value on every path, but one path falls off the end instead. Adding the return null; that the annotation already implies resolves the report without changing behavior, since PHP was returning null implicitly anyway. This is the shape r61716 used on get_category_by_path(), which replaced a bare return; in that same function; its remaining path is now handled too.

Covered here are get_category_by_path(), wp_list_users(), single_month_title(), WP_Customize_Manager::get_setting(), get_panel(), get_section() and get_control(), WP_Customize_Widgets::get_setting_type(), WP_Customize_Header_Image_Control::get_current_image_src(), WP_Image_Editor_Imagick::set_imagick_time_limit(), and the four pagination helpers in link-template.php.

Every change is a pure append, leaving the diff additive at 30 insertions and no deletions. Two further groups of return.missing fixes from the same pull request carry more risk and will follow separately.

The baseline tests/phpstan/baselines/return.missing.neon drops from 41 entries covering 44 errors to 27 covering 29, so the file and its entry in phpstan.neon.dist both remain for now.

Developed in https://github.com/WordPress/wordpress-develop/pull/13082.
Follow-up to r61716, r63020.

Props dpantazis, dmsnell.
See #65817.

File:
1 edited

Legend:

Unmodified
Added
Removed
Note: See TracChangeset for help on using the changeset viewer.