Skip to content

[10.x] Update Facade::$app to nullable - #50260

Merged
taylorotwell merged 1 commit into
laravel:10.xfrom
villfa:patch-2
Feb 26, 2024
Merged

taylorotwell merged 1 commit into
laravel:10.xfrom
villfa:patch-2

Conversation

@villfa

@villfa villfa commented Feb 26, 2024

Copy link
Copy Markdown
Contributor

Facade::$app can be null.
There are already some nullability checks within the same class (see swap() or resolveFacadeInstance()).

Making it explicit in the PHP blocks allows us to avoid errors with static analysis tools like PHPStan:

Parameter #1 $app of static method Illuminate\Support\Facades\Facade::setFacadeApplication() expects Illuminate\Contracts\Foundation\Application, null given.

@taylorotwell
taylorotwell merged commit b8b71e0 into laravel:10.x Feb 26, 2024
@villfa
villfa deleted the patch-2 branch February 26, 2024 17:10
@jose123v

jose123v commented Feb 28, 2024 •

Copy link
Copy Markdown
Contributor

@taylorotwell this breaks PHPStan and other analysis tools on laravel 10.x,
on 8.x, 9.x, 11.x works because these don't have this change

Error: Cannot call method make() on Illuminate\Contracts\Foundation\Application|null.
 ------ --------------------------------------------------- 
  53     Cannot call method make() on                       
         Illuminate\Contracts\Foundation\Application|null.  
 ------ --------------------------------------------------- 

CC: @driesvints

@driesvints

Copy link
Copy Markdown
Member

@jose123v can you share a full stack trace?

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