Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#903 0 comments 0 reactions 0 assignees View on GitHub

@tomjn is already working on this.

Since Oct 2, 2026.

  • #905 by @tomjn — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
tooling

Research direction

Start at AlwaysReturnInFilterSniff::isInsideIfConditonal() and inspect how the token's conditions array is read. Simplify the guard and reset logic as described, then verify the sniff still reports the same cases; done means the tidy-up preserves reporting behavior.

Written by the indexing model from the issue text.

Description

This is a tidy-up. It does not change what the sniff reports.

AlwaysReturnInFilterSniff::isInsideIfConditonal() decides whether a return in a filter callback sits inside an if. It has a guard for a token that has no conditions array, but the guard comes after two end() calls that have already read that array, so it protects nothing. PHP_CodeSniffer sets conditions on every token, so the guard is not needed in the first place.

The reset() call between the two has no effect on the result either. It only undoes the array pointer move that end() made on the shared token array.

The method can read the array once, return false when the innermost condition is a function or closure, and otherwise return in_array( T_IF, $conditions, true ).

@GaryJones spotted this while reviewing #901. It was left out of that PR because that one only adds return types.

Dominant language
PHP
Stars
261
Forks
44
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/VIP-Coding-Standards

All issues in Automattic/VIP-Coding-Standards

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.