WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 2 months ago

Last modified 2 months ago

#54377 closed feature request (fixed)

Introduce new PHP cross-version compatibility functions, `str_ends_with()`

Reported by: pbiron Owned by: hellofromTonya
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: General Keywords: php8 has-patch has-unit-tests commit
Focuses: Cc:

Description

PHP 8 added a str_ends_with() function.

It would be good to add a polypill for it to core, so that plugins that use it will work on sites running PHP < 8.

I'll do a patch with unit tests tomorrow.

Related: #45055, #49652

Change History (13)

#1 @hellofromTonya
3 months ago

  • Owner set to hellofromTonya
  • Status changed from new to accepted

Accepting this feature as it can be bundled with the other PHP polyfills.

This ticket was mentioned in Slack in #core-php by hellofromtonya. View the logs.


3 months ago

#3 @hellofromTonya
3 months ago

  • Keywords php8 added

#4 @pbearne
3 months ago

there is a str_starts_with()

#5 @pbiron
3 months ago

Thanx @pbearne! (hi, by the way :-)

I was just coming to add a comment that I will also include a polyfill for str_starts_with() as well.

This ticket was mentioned in PR #1811 on WordPress/wordpress-develop by pbearne.


3 months ago

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

This ticket was mentioned in Slack in #core-php by pbearne. View the logs.


3 months ago

#8 @pbiron
3 months ago

@pbearne Thanx for the PR Paul. I just made a few comments/suggestions for corrections to it.

@hellofromTonya Would appreciate you also looking at those comments.

#9 @hellofromTonya
2 months ago

  • Keywords commit added

Thanks @pbiron for the ping. Did a thorough review. Ready for commit.

#10 @hellofromTonya
2 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 52040:

General: Introduce polyfills for str_ends_with() and str_starts_with() added in PHP 8.0.

PHP 8.0 introduced two new functions: str_ends_with() and str_starts_with(). These perform a case-sensitive check indicating if the string to search in (haystack) ends or begins with the given substring (needle).

These polyfills make these functios available for use in Core.

Ref:

Props costdev, hellofromTonya, pbearne, pbiron.
Fixes #54377.

#12 @hellofromTonya
2 months ago

Thank you everyone for your contributions! These functions are now available for use in Core.

This ticket was mentioned in Slack in #core by sergey. View the logs.


2 months ago

Note: See TracTickets for help on using tickets.