AlwaysReturnInFilter: isInsideIfConditonal() guards the conditions array after reading it
関連するプルリクエストがすでにマージされています。
- #905 @tomjn による — マージ済み
評価
調査の方向性
AlwaysReturnInFilterSniff::isInsideIfConditonal() から始めて、トークンの conditions 配列がどのように読み取られているかを調べます。説明されているとおりに guard と reset のロジックを簡素化し、その後も sniff が同じケースを報告することを確認します。整理によって報告動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- PHP
- スター
- 261
- フォーク
- 44
- 平均マージ
- 3日 17時間
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Automattic/VIP-Coding-Standards のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
Breaking Change Type: Maintenance
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Automattic/VIP-Coding-Standards#849 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
WordPress.WP.AlternativeFunctions.file_system_operations error messages cannot be fixed anymoreオープン
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
Status: Awaiting feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
Automattic/VIP-Coding-Standards#754 · コメント 3 件 ·
Automattic/VIP-Coding-Standards の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Automattic/blocks-engine#2866 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
community-scripts/ProxmoxVE#17944 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
backend gamification P0
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
semanadeinformatica/website#461 ·
-
HttpRequestTrait fatals on WordPress 7.2: $blocked_http_requests clashes with WP_UnitTestCase_Baseオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100