lint/style/prefer-str-contains
In the lint-strict preset. In Rector’s rector/php-polyfills, rector/php80 sets. Unsafe fix: it can change behavior.
What it does
Replace strpos() and stripos() calls with str_starts_with() or str_contains() if possible.
Configuration
[lint.rules]
"style/prefer-str-contains" = "error"
To skip it in some files, add an override or a @pun-ignore-file comment.
Options
| Name | Type | Allowed values | Default | Upstream name |
|---|---|---|---|---|
modernize-stripos |
bool |
Any | false |
modernize_stripos |
Replaces
modernize_strpos(php-cs-fixer, risky)StrContains(rector)str-contains(mago-linter)str-starts-with(mago-linter)