Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Refactor string checks to use str_starts_with and str_contains functions#438

Merged
dkotter merged 3 commits intoWordPress:developfrom
Soean:refactor_strpos
Apr 20, 2026
Merged

Refactor string checks to use str_starts_with and str_contains functions#438
dkotter merged 3 commits intoWordPress:developfrom
Soean:refactor_strpos

Conversation

@Soean
Copy link
Copy Markdown
Member

@Soean Soean commented Apr 16, 2026

What?

This pull request updates several string handling operations to use more modern and readable PHP string functions. The changes improve code clarity and maintainability by replacing older strpos patterns with str_starts_with and str_contains.

Changelog Entry

Changed - Refactor strpos to str_starts_with and str_contains.

Open WordPress Playground Preview

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Soean <soean@git.wordpress.org>
Co-authored-by: justlevine <justlevine@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.44%. Comparing base (7d98557) to head (5789bf7).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
includes/Abilities/Image/Alt_Text_Generation.php 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #438   +/-   ##
==========================================
  Coverage      68.44%   68.44%           
  Complexity       846      846           
==========================================
  Files             56       56           
  Lines           4095     4095           
==========================================
  Hits            2803     2803           
  Misses          1292     1292           
Flag Coverage Δ
unit 68.44% <33.33%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Collaborator

@dkotter dkotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So PHPStan is failing here as it can't find these functions. I think because they don't exist in PHP 7.4, though they are safe for us to use as WordPress polyfills these. Ideally we'll need to find a way to make PHPStan happy here before merging

@justlevine
Copy link
Copy Markdown
Contributor

Ideally we'll need to find a way to make PHPStan happy here before merging

Done in 5789bf7

Prior art: https://github.com/WordPress/performance/blob/518db24b7606bf7ffda33f0ebba65b5d1e906686/phpstan.neon.dist#L16-L20

@justlevine justlevine requested a review from dkotter April 19, 2026 22:58
@dkotter dkotter merged commit 1ee0a9b into WordPress:develop Apr 20, 2026
17 of 18 checks passed
@github-project-automation github-project-automation Bot moved this from Needs review to Done in WordPress AI Planning & Roadmap Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants