calebdw/phpstan-laravel

A PHPStan extension for analysis of Laravel applications and packages.

Maintainers

Package info

github.com/calebdw/phpstan-laravel

Homepage

Documentation

Type:phpstan-extension

pkg:composer/calebdw/phpstan-laravel

Transparency log

Fund package maintenance!

calebdw

Statistics

Installs: 159

Dependents: 2

Suggesters: 0

Stars: 6

Open Issues: 0

v1.5.0 2026-08-25 21:18 UTC

This package is auto-updated.

Last update: 2026-08-26 02:40:08 UTC


README

phpstan-laravel

Teaches PHPStan about Laravel's magic

Latest Version Laravel Compatibility PHP Compatibility Laravel Boost Total Downloads Tests License

phpstan-laravel.dev

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.

To get started, take a look at the official documentation: installation, configuration, every rule, every option and identifier, and the guide for moving over from Larastan.

Contributing

Contributions are welcome: see CONTRIBUTING.md.

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.