Repository navigation
Remove redundant truthiness checks after ! empty() - #86094
Merged
westonruter merged 2 commits intoNov 1, 2026
Merged
westonruter merged 2 commits into
westonruter merged 2 commits into
Conversation
`! empty( $value ) && $value` checks the same thing twice, since `! empty()` is only true for truthy values. Drop the second check in the Categories, Comments Title, and Navigation blocks and in the typography block support, which matches WordPress Core. Remove the 5 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 02:33
huzaifaalmesbah
requested review from
fabiankaegy,
manzoorwanijk and
spacedmonkey
as code owners
November 1, 2026 02:33
…t-conditions # Conflicts: # tools/phpstan/baseline.neon
manzoorwanijk
approved these changes
Nov 1, 2026
westonruter
approved these changes
Nov 1, 2026
Vedant-Gandhi
pushed a commit
to Vedant-Gandhi/gutenberg
that referenced
this pull request
Nov 30, 2026
`! empty( $value ) && $value` checks the same thing twice, since `! empty()` is only true for truthy values. Drop the second check in the Categories, Comments Title, and Navigation blocks and in the typography block support, which matches WordPress Core. Remove the 5 resolved entries from the PHPStan baseline. See WordPress#86088. Co-authored-by: huzaifaalmesbah <huzaifaalmesbah@git.wordpress.org> Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
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
Removes redundant truthiness checks that follow
! empty(), and removes the resolved entries from the PHPStan baseline.Why?
! empty( $value ) && $valuechecks the same thing twice:! empty()is only true when the value is set and truthy, so the right side of&&is always true. PHPStan reports these asbooleanAnd.rightAlwaysTrue. Together, these changes clear 5 of the 226 errors initially baselined in #66693.How?
Dropped the redundant right-hand check in:
showOnlyTopLevelshowPostTitleandshowCommentsCountisResponsivelib/block-supports/typography.php):fitText. WordPress Core already has the simplified condition, so this brings Gutenberg in line with Core.Removed the 5 corresponding entries from
tools/phpstan/baseline.neon.There is no change in behavior.
Testing Instructions
composer phpstanand confirm it passes with no unmatched ignored errors.composer phpstan:baselinesand confirmtools/phpstan/baseline.neonhas no further changes.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.