Looking to hire Laravel developers? Try LaraJobs

phpstan-laravel maintained by calebdw

Description
A PHPStan extension for analysis of Laravel applications and packages.
Author
Last update
2026/08/25 00:04 (dev-master)
License
Downloads
11

Comments
comments powered by Disqus

Laravel leans on magic: facades, container bindings, dynamic Eloquent properties, method forwarding, macros. A static analyser sees almost none of it on its own, so the parts of your application that carry the most behaviour are the parts it checks least.

This PHPStan extension closes that gap. It boots your application during analysis and combines that with stubs, reflection extensions and schema scanning, so PHPStan can reason about your models, relations, collections, configuration and views.

$user = User::query()->firstOrFail();   // App\User

$user->email;                           // string
$user->emial;                           // Access to an undefined property
$user->accounts;                        // App\AccountCollection<int, App\Account>

User::query()->pluck('name');           // Collection<int, string>
$user->accounts()->pluck('name');       // Collection<int, string>
User::all()->groupBy('email');          // Collection<string, Collection<int, App\User>>

config('auth.defaults.guard');          // string|null
Config::string('auth.defaults.guard');  // string

User::create(['emial' => '...']);       // Property 'emial' does not exist

None of it comes from annotations you write, and it ships rules for the mistakes Laravel will happily let you make at runtime. It works at every PHPStan level, on applications and on packages.

Everything else is at phpstan-laravel.dev: installation, configuration, every rule, every option and identifier, and the guide for moving over from Larastan.

Contributing

Contributions are welcome: see CONTRIBUTING.md to get started.

Acknowledgments

This package began as a fork of larastan/larastan, created by Can Vural and Nuno Maduro and improved by many contributors over the years. It would not exist without their work.

License

Open-sourced software licensed under the MIT license.