Make WordPress Core


Ignore:
Timestamp:
08/27/2026 10:33:18 PM (2 months 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
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r62878 r63378  
    38763876                        return $this->settings[ $id ];
    38773877                }
     3878
     3879                return null;
    38783880        }
    38793881
    … …  
    39283930                        return $this->panels[ $id ];
    39293931                }
     3932
     3933                return null;
    39303934        }
    39313935
    … …  
    40244028                        return $this->sections[ $id ];
    40254029                }
     4030
     4031                return null;
    40264032        }
    40274033
    … …  
    41034109                        return $this->controls[ $id ];
    41044110                }
     4111
     4112                return null;
    41054113        }
    41064114
Note: See TracChangeset for help on using the changeset viewer.