nunomaduro/larastan
Larastan is a PHPStan extension for Laravel that adds strong type inference and “code analysis” by booting the app container. It understands Laravel’s magic, finds bugs early, and improves code quality and developer productivity.
phpstan.neon for project-specific needs.Collection, Model casts).mixed return types) before they impact runtime.Adopt Larastan if:
@return, @var) for better type inference.null but is documented as @return int").Look elsewhere if:
call_user_func) that static analysis struggles with.For Executives: *"Larastan turns Laravel’s ‘magic’ into a competitive advantage. By integrating static analysis into our workflow, we’ll:
null returns, undefined methods).For Engineering Teams: *"Larastan is like PHPStan on steroids for Laravel. It:
composer.json, configure phpstan.neon, and run ./vendor/bin/phpstan analyse in CI.
Start with Level 3 (moderate) to avoid burnout, then ramp up. Ignore known false positives (see errors-to-ignore.md) and focus on high-impact fixes first."For Developers: *"This is your new best friend for:
Model, Collection, etc../vendor/bin/phpstan analyse --memory-limit=2G).
Pro tip: Use @phpstan-ignore-line sparingly—aim to fix the root cause. And if you’re stuck, check the rules docs for Laravel-specific fixes."How can I help you explore Laravel packages today?