Skip to content

Conversation

@balping
Copy link
Contributor

@balping balping commented Dec 1, 2020

In PHP 8, functions str_starts_with(), str_ends_with() and str_contains() were introduced. These are considered superior to userland implementations.

This PR reimplements Str::startsWith, Str::endsWith, and Str::contains using the new built-in functions, while keeping backwards compatibility.

Note: in laravel/helpers, function str_contains() is already defined.To avoid infinite recursion for users using PHP 7 and the helpers package, in this PR for Str::contains PHP version is checked rather than the existence of str_contains().

@driesvints
Copy link
Member

We shouldn't be using these version checks in the framework. We can make use of these functions once PHP 8 is the minimum version. This doesn't really improve anything atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants