lint/complexity/prefer-in-array
In the code-quality set. Safe fix.
What it does
Use in_array() instead of repeated ||/&& comparisons, array_search() checks and foreach loops.
Configuration
[lint.rules]
"complexity/prefer-in-array" = "error"
To skip it in some files or lines, add an override or an ignore comment.
Options
| Name | Type | Allowed values | Default | Upstream name |
|---|---|---|---|---|
checks |
list |
array-search, foreach, repeated-or |
["array-search", "foreach", "repeated-or"] |
None (Pun’s own) |
Replaces
ForeachToInArray(rector)RepeatedOrEqualToInArray(rector)SimplifyArraySearch(rector)
Merged rules
These old IDs are now this rule. A config that still names one stops with an error. See merged rules.
lint/complexity/prefer-in-array-over-searchlint/complexity/prefer-in-array-over-foreach