laravel / browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel release.
MIT License
509 stars 75 forks source link

ADD Null Safety #170

Closed allanlaal closed 1 year ago

allanlaal commented 1 year ago

add Null safety to whereever appropriate, so things like this wouldn't be fatal:

ErrorException

  Trying to access array fset on value of type null

  at vendor/laravel/browser-kit-testing/src/Concerns/ImpersonatesUsers.php:32
     28▕      * @return void
     29▕      */
     30▕     public function be(UserContract $user, $driver = null)
     31▕     {
  ➜  32▕         $this->app['auth']->guard($driver)->setUser($user);
     33▕     }
     34▕ }
     35▕ 
allanlaal commented 1 year ago

in my example, the fix would be:

$this->app?->auth->guard($driver)->setUser($user);

driesvints commented 1 year ago

No plans for this sorry. Most likely you're using this incorrectly. Please try a support channel: