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

Deprecation warning, passing null to str_contains() - Middleware Permission #651

Closed
lucasjose501 opened this issue Oct 31, 2023 · 1 comment

Comments

@lucasjose501
Copy link

Not sure if this is a problem with Laratrust or Str::contains, but when I use the middleware like this in the constructor:

    public function __construct()
    {
        $this->middleware('permission:admin.index');
    }

I get this warning:
str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in my_app_path/vendor/laravel/framework/src/Illuminate/Support/Str.php on line 269

To see the warning I used LOG_DEPRECATIONS_CHANNEL=single in the environment.

This warning happens in the function GetValuesFromParameter at LaratrustMiddleware.php when $team is null.

'team' => Str::contains($team, ['require_all', 'guard:']) ? null : $team,

I tested locally changing the line to Str::contains($team ?? '', ['require_all', 'guard:']) ? null : $team and it removes the warning, but I'm not sure if this is the correct solution.

I'm using Laratrust 8.2.1 and Laravel v10.28.0

@filippotoso
Copy link
Collaborator

A pull request that fixes this isse has been created.

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

No branches or pull requests

2 participants