Skip to content

Conversation

@seriquynh
Copy link
Contributor

Because http component requires illuminate/collections package, we can use collection inside Request class. One more thing is Laravel v9 requires PHP >= 8.0, we also can use arrow functions right here. In this pull request, I replace two foreach statements by two one-line collection contains method.

Before

foreach ($patterns as $pattern) {
    if (Str::is($pattern, $path)) {
        return true;
    }
}

return false;

After

return collect($patterns)->contains(fn ($pattern) => Str::is($pattern, $path));

@taylorotwell taylorotwell merged commit 6cb52b2 into laravel:master Dec 1, 2021
@seriquynh seriquynh deleted the repleace-foreach branch June 14, 2024 01:09
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.

2 participants