WordPress / WordPress/WordPress-Coding-Standards

Add a lint for `strpos` !== false to use str_contains

Open
#2,261 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: Core Focus: Modern PHP Upstream: PHPCSExtra
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.