Repository navigation
Block Library: Return values matching the documented types instead of empty returns - #86091
Merged
westonruter merged 1 commit intoNov 1, 2026
Conversation
… empty returns Several block render callbacks and helper functions used a bare `return;`, returning `null` although their documented return type is `string` or `array`. Return an empty string or an empty array instead, and document that the deprecated `block_core_navigation_maybe_use_classic_menu_fallback()` returns `WP_Post|null`. Remove the 21 resolved entries from the PHPStan baseline. See WordPress#86088.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
huzaifaalmesbah
marked this pull request as ready for review
November 1, 2026 01:42
huzaifaalmesbah
requested review from
fabiankaegy and
manzoorwanijk
as code owners
November 1, 2026 01:42
westonruter
approved these changes
Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
See #86088
Replaces bare
return;statements in block render callbacks and helper functions with return values that match their documented return types, and removes the resolved entries from the PHPStan baseline.Why?
PHPStan reports
return.emptywhen a function documented to returnstringorarrayuses a barereturn;, which actually returnsnull. Together, these changes clear 21 of the 226 errors initially baselined in #66693 (all 20return.emptyerrors plus one relatedreturn.typeerror).How?
'': Comment Reply Link, Comment Template, Comments Pagination, Comments Title, Icon, Page List, Post Comments Form, and Site Tagline.WP_Block::render()casts the callback result to a string, so the rendered output is unchanged.block_core_page_list_render_nested_page_list()returns'', andblock_core_page_list_nest_pages()returnsarray(). Callers only concatenate the markup or pass the pages on to the renderer, which already returns early for empty input.block_core_navigation_get_menu_items_at_location()returnsarray(). Both callers check the result withempty(), so they behave the same.block_core_navigation_maybe_use_classic_menu_fallback()actually returns the result ofblock_core_navigation_get_most_recently_published_navigation(), so its@returnis corrected toWP_Post|nulland the early returns are now an explicitreturn null;.tools/phpstan/baseline.neon.Testing Instructions
composer phpstanand confirm it passes with no unmatched ignored errors.npm run test:php -- --filter "Tests_Blocks_Render|page_list|navigation|comment".Testing Instructions for Keyboard
Not applicable. There are no UI changes.
Screenshots or screencast
Not applicable.
Use of AI Tools
I used Claude Code to identify the affected occurrences and draft the change. I reviewed the diff and take responsibility for it.