Larastan is a static analysis extension and type inference engine for PHP designed to detect bugs and type errors in Laravel applications. It extends PHPStan to resolve framework-specific patterns and magic methods, providing a rule-based scanning engine to audit code quality without executing the application.
The tool specializes in Eloquent analysis, verifying that model properties, casts, and relationships align with database schemas and migrations. It tracks types across Eloquent collections, custom builders, and model factories to ensure type safety during database operations and iteration.
Broad capability areas include configuration validation, view path verification, and the detection of inefficient database queries or redundant collection calls. The engine also audits job dispatch arguments, localization keys, and compatibility with long-running process environments.
Diagnostics include styled bootstrap error reporting to resolve startup failures, as well as mechanisms for error suppression and the establishment of legacy issue baselines.