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

[11.x] Remove $except property from ExcludesPaths trait #50644

Merged
merged 2 commits into from
Mar 19, 2024

Conversation

gdebrauwer
Copy link
Contributor

@gdebrauwer gdebrauwer commented Mar 19, 2024

It is currently impossible to set the $except property in a class when using the ExcludesPaths trait.

class FooBarMiddleware
{
    use ExcludesPaths;

    protected $except = [
        '/some/excluded/path', // adding a value here causes an error
    ];

    public function handle($request, $next)
    {
        // ...
    }
}

This causes the following error:

PHP Fatal error: App\Http\Middleware\FooBarMiddleware and Illuminate\Foundation\Http\Middleware\Concerns\ExcludesPaths define the same property ($except) in the composition of App\Http\Middleware\FooBarMiddleware. However, the definition differs and is considered incompatible.

This is caused by the fact that the $except property is already set in trait. Removing it from the trait fixes that.

@driesvints
Copy link
Member

This is a breaking change for anyone applying this trait.

@gdebrauwer
Copy link
Contributor Author

This trait has only been added in Laravel 11.
If I change the getExcludedPaths() method so it returns an empty array if $except does not exist or is not set, is it still a breaking change in that case?

@driesvints
Copy link
Member

@gdebrauwer that helps!

@taylorotwell taylorotwell merged commit e6d01af into laravel:11.x Mar 19, 2024
28 checks passed
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