lint/php-8.4/prefer-array-find
In the modernize set. Safe fix. Gated by php-8.4.
What it does
Replace foreach loops with array_find(), array_find_key(), array_any() or array_all() (PHP 8.4).
Configuration
[lint.rules]
"php-8.4/prefer-array-find" = "error"
To skip it in some files or lines, add an override or an ignore comment.
Options
| Name | Type | Allowed values | Default | Upstream name |
|---|---|---|---|---|
functions |
list |
array-all, array-any, array-find, array-find-key |
["array-all", "array-any", "array-find", "array-find-key"] |
None (Pun’s own) |
Replaces
ForeachToArrayAll(rector)ForeachToArrayAny(rector)ForeachToArrayFind(rector)ForeachToArrayFindKey(rector)
Merged rules
These old IDs are now this rule. A config that still names one stops with an error. See merged rules.
lint/php-8.4/prefer-array-alllint/php-8.4/prefer-array-anylint/php-8.4/prefer-array-find-key