Skip to content

Read the conditions once in AlwaysReturnInFilter's isInsideIfConditonal() - #905

Merged
GaryJones merged 1 commit into
Automattic:developfrom
tomjn:fix/903-always-return-in-filter-conditions
Oct 9, 2026
Merged

GaryJones merged 1 commit into
Automattic:developfrom
tomjn:fix/903-always-return-in-filter-conditions

Conversation

@tomjn

@tomjn tomjn commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

A tidy-up @GaryJones spotted while reviewing #901. It does not change what the sniff reports.

The guard for a missing conditions array ran after the array had already been read, and PHP_CodeSniffer sets conditions on every token anyway, so the guard is gone.

Fixes #903

The guard for a missing conditions array came after two end() calls that had already read it. PHP_CodeSniffer sets conditions on every token, so the guard goes. Working on a copy also removes the need for reset(), which was there to undo end() moving the pointer on the shared token array.
@tomjn
tomjn requested a review from a team as a code owner October 2, 2026 15:20
@GaryJones GaryJones added this to the 3.x milestone Oct 9, 2026
@GaryJones
GaryJones merged commit df1e425 into Automattic:develop Oct 9, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AlwaysReturnInFilter: isInsideIfConditonal() guards the conditions array after reading it

2 participants