You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AlwaysReturnInFilter: isInsideIfConditonal() guards the conditions array after reading it #903
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.
Activity