Replace strpos/substr with str_starts_with() / str_contains() / str_ends_with()

Created on 30 November 2022, almost 2 years ago
Updated 29 April 2024, 7 months ago

Problem/Motivation

PHPStorm can automatically replace strpos and substr with the applicable PHP 8 function for more readable and easier to grok code.

Steps to reproduce

Run the PHPStorm scanner and fixer.

Proposed resolution

Do it. Decide if we want to backport to Drupal 9.5 (we have a polyfil).

Remaining tasks

  1. πŸ“Œ Replace most strpos() === 0 or !== 0 with str_starts_with() Fixed
  2. πŸ“Œ Replace most strpos() !== FALSE or === FALSE with str_contains() Fixed
  3. πŸ“Œ Replace substr($a, 0, $i) with str_starts_with() Fixed
  4. πŸ“Œ Replace most substr($a, $i) where $i is negative with str_ends_with() Fixed
  5. Review MR
  6. Commit

User interface changes

API changes

Data model changes

Release notes snippet

🌱 Plan
Status

Fixed

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 27 minutes ago

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024