Open
Description
Rector proposes the following change, but there is no injection in service providers. The constructor requires an Application instance $app
as it's first (and only) argument.
class AppServiceProvider extends ServiceProvider
{
+ public function __construct(private readonly \Illuminate\Contracts\Auth\Access\Gate $gate)
+ {
+ }
public function boot(): void
{
- Gate::before(fn ($user, $ability) => $user->email === '***');
+ $this->gate->before(fn ($user, $ability) => $user->email === '***');
}
}
----------- end diff -----------
The accepted code will throw an exception:
App\Providers\AppServiceProvider::__construct(): Argument # 1 ($gate) must be of type Illuminate\Contracts\Auth\Access\Gate, Illuminate\Foundation\Application given
rector/rector: 2.0.10
driftingly/rector-laravel: 2.0.2
laravel/framework: 11.44.2
Metadata
Metadata
Assignees
Labels
No labels