strpos($a, $b) which compares with FALSE or 0 should replace with str_contains($a, $b) or str_starts_with($a, $b) if possible

Created on 13 May 2025, 24 days ago

Problem/Motivation

In Drupal core, strpos() which compares with FALSE or 0 is already replaced in 🌱 Replace strpos/substr with PHP 8's str_starts_with() / str_contains() / str_ends_with() Active . Now str_contains() and str_starts_with() can use since PHP 8 so module supporting Drupal 10+ can replace these code.

Proposed resolution

strpos($a, $b) compares with FALSE or 0 replace like following list if possible.

  1. strpos($a, $b) !== FALSE replace with str_contains($a, $b)
  2. strpos($a, $b) === FALSE replace with !str_contains($a, $b)
  3. strpos($a, $b) === 0 replace with str_starts_with($a, $b)
  4. strpos($a, $b) !== 0 replace with !str_starts_with($a, $b)

Remaining tasks

TBD

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

6.3

Component

Code

Created by

🇯🇵Japan tom konda Kanagawa, Japan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024