WordPress / WordPress/WordPress-Coding-Standards
Add a lint for `strpos` !== false to use str_contains
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
Is your feature request related to a problem?
Describe the solution you'd like
Add a lint for strpos !== false to use ! str_contains and the opposite. See https://github.com/WordPress/wordpress-develop/commit/9e9887d8b8fa49685c484ee606748e1f0aca1bf9. str_contains is a php 8.0 function but a polyfill was added in core in WP 5.9. https://github.com/WordPress/wordpress-develop/commit/3cc8f1237a737ccf895682029afacafd7305d420
Additional context (optional)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start by reviewing the existing PHP_CodeSniffer rules and the two linked WordPress commits, then identify where a sniff for strpos comparisons belongs; done means both strpos !== false and the opposite form are linted toward the corresponding str_contains usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100