Skip to content
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

[8.x] Fix route groups with no prefix on PHP 8.1 #39115

Merged
merged 2 commits into from
Oct 7, 2021
Merged

[8.x] Fix route groups with no prefix on PHP 8.1 #39115

merged 2 commits into from
Oct 7, 2021

Conversation

GuardsmanPanda
Copy link
Contributor

In php 8.1 calling trim() on null values is deprecated and since my route collection have groups without a defined prefix, I get an error on this line of code.

Parsing in an empty string as opposed to null is the minimal change which solves the problem.

In php 8.1 calling trim() on null values is deprecated and since my route collection have groups without a defined prefix, I get an error on this line of code.
Parsing in an empty string as opposed to null is the minimal change which solves the problem.
@GrahamCampbell GrahamCampbell changed the title PHP 8.1, fix route groups with no prefix. [8.x] PHP 8.1, fix route groups with no prefix. Oct 6, 2021
@GrahamCampbell
Copy link
Member

Thanks for the PR. Are you able to add test coverage here too, please?

@GuardsmanPanda
Copy link
Contributor Author

GuardsmanPanda commented Oct 6, 2021

I should have some time to do that shortly, I'm also adding the failing code here in the comment so you can verify (in case I forget about this PR).

class RouteServiceProvider extends ServiceProvider {
    public function boot():void {
        $this->routes(function () {
            Route::middleware(['cookie', 'session'])->group(function() {
                Route::prefix('')->group(base_path('path/to/routes.php'));
            });
        });
    }
}

@GrahamCampbell
Copy link
Member

cc @driesvints

@GrahamCampbell GrahamCampbell changed the title [8.x] PHP 8.1, fix route groups with no prefix. [8.x] Fix route groups with no prefix on PHP 8.1 Oct 7, 2021
@GuardsmanPanda
Copy link
Contributor Author

@driesvints @GrahamCampbell I added a testcase which fails on 8.1 without this change.

@taylorotwell taylorotwell merged commit a683198 into laravel:8.x Oct 7, 2021
victorvilella pushed a commit to cdsistemas/framework that referenced this pull request Oct 12, 2021
* PHP 8.1, fix route groups with no prefix.

In php 8.1 calling trim() on null values is deprecated and since my route collection have groups without a defined prefix, I get an error on this line of code.
Parsing in an empty string as opposed to null is the minimal change which solves the problem.

* Added test cast for grouped route without prefix
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.

4 participants