8000 [8.x] Make use of new PHP8 string functions by balping · Pull Request #35439 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content
8000

[8.x] Make use of new PHP8 string functions #35439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

[8.x] Make use of new PHP8 string functions #35439

wants to merge 1 commit into from

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
0