Skip to content

ContextHelper::is_in_array_comparison(): add basic tests#2726

Merged
jrfnl merged 2 commits into
developfrom
is-in-array-comparison-tests
Apr 27, 2026
Merged

ContextHelper::is_in_array_comparison(): add basic tests#2726
jrfnl merged 2 commits into
developfrom
is-in-array-comparison-tests

Conversation

@rodrigoprimo
Copy link
Copy Markdown
Contributor

@rodrigoprimo rodrigoprimo commented Apr 23, 2026

Description

In preparation for supporting PHPCS 4.0, this PR adds unit tests for the ContextHelper::is_in_array_comparison() method.

Suggested changelog entry

N/A

Related issues/external references

Related to: #2272

@rodrigoprimo
Copy link
Copy Markdown
Contributor Author

I added a new commit with a negative bare variable test as suggested in #2725 (review) for consistency.

@jrfnl jrfnl added this to the 3.4.0 milestone Apr 27, 2026
@jrfnl jrfnl force-pushed the is-in-array-comparison-tests branch from 9ccc62d to 94dfbaa Compare April 27, 2026 12:42
Copy link
Copy Markdown
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rodrigoprimo ! Looking good again.

One thing I would like to point out - but not a blocker -: these helper functions generally can target any arbitrary token to check if that token is "in an array comparison" or "in isset".

All the tests specifically target variables though, which makes them a little one-dimensional (but doesn't take anything away from the value of having those tests). Having some variation - a test targetting a T_COMMA or a T_STRING function call or constant or something, would also document better that the functions can be used on any type of token.

@jrfnl jrfnl merged commit 22d4758 into develop Apr 27, 2026
42 checks passed
@jrfnl jrfnl deleted the is-in-array-comparison-tests branch April 27, 2026 12:49
lesterchan added a commit to lesterchan/WordPress-Coding-Standards that referenced this pull request May 4, 2026
* upstream/develop: (223 commits)
  ContextHelper::is_in_type_test(): add tests (WordPress#2721)
  WPDBTrait::is_wpdb_method_call(): improve docblock description (WordPress#2719)
  ContextHelper::is_in_array_comparison(): add basic tests (WordPress#2726)
  ContextHelper::is_in_isset_or_empty(): add basic tests (WordPress#2725)
  WP/I18n: add tests for namespaced names
  WP/GetMetaSingle: add tests for namespaced names
  WP/DeprecatedParameterValues: add tests for namespaced names
  WP/DeprecatedParameterValues: move syntax error test to its own file
  WP/DeprecatedParameterValues: rename test case file
  WP/DeprecatedParameters: add tests for namespaced names
  FormattingFunctionsHelper::is_formatting_function(): add tests (WordPress#2713)
  UnslashingFunctionsHelper::is_unslashing_function(): add tests (WordPress#2715)
  GH Actions: Bump crate-ci/typos from 1.44.0 to 1.45.0 in the action-runners group (WordPress#2717)
  GH Actions: Bump codecov/codecov-action from 5.5.3 to 6.0.0
  GH Actions: Bump ramsey/composer-install from 3.1.1 to 4.0.0
  GH Actions: Bump the action-runners group with 2 updates
  Security/ValidatedSanitizedInput: add tests for namespaced names
  Apply suggestion from PR review
  WP/EnqueuedResourceParameters: add tests for namespaced names (WordPress#2675)
  GH Actions: Bump crate-ci/typos in the action-runners group
  ...
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.

3 participants