Today, @can__vural, @szepeviktor and I are proud to announce the release of Larastan v0.5.
You don't know what Larastan is? It's a console tool that adds static analysis to Laravel improving developer productivity and code quality. Static analysis is the art of trying to spot problems in your source code before it’s run.
As example, if you try to assign a string
instead of a array
on the User::$guard
model you will get this:
class User extends Model
{
protected $guarded = ''; // Error
}

This new version includes several bug fixes, adds support to Laravel 7, and is built on top of PHPStan 0.12. Note that, PHPStan 0.12 is a massive release that has been in the works for the past six months by the PHPStan team and introduces all the features detailed here: medium.com/@ondrejmirtes/phpstan-0-12-released-f1a88036535d.
Note: Are you using Larastan 0.4? Here is the upgrade guide: github.com/nunomaduro/larastan/blob/master/UPGRADE.md.
Getting Started in 3 Steps
Requires:
1: First, you may use Composer to install Larastan as a development dependency into your Laravel project:
composer require --dev nunomaduro/larastan
Using Larastan for analyzing Laravel packages? You may need to install orchestra/testbench
.
2: Then, create a phpstan.neon
or phpstan.neon.dist
file in the root of your application. It might look like this:
includes:
- ./vendor/nunomaduro/larastan/extension.neon
parameters:
paths:
- app
# The level 7 is the highest level
level: 5
ignoreErrors:
- '#Unsafe usage of new static#'
excludes_analyse:
- ./*/*/FileToBeExcluded.php
checkMissingIterableValueType: false
For all available options, please take a look at the PHPStan documentation: https://github.com/phpstan/phpstan
3: Finally, you may start analyzing your code using the PHPStan console command:
./vendor/bin/phpstan analyse
Thanks, we hope you enjoy this new release! 🎉