Many developers rely on some software that helps to check the code. Clean code that follows predefined rules makes further development and support much more manageable, so spending a bit more time now, they get a chance to save much more time later. One of such tools is Larastan – a static analysis command-line tool that uses PHPStan as its base. Many developers who worked with PhpStorm may have had encounter the latter one. It allows finding errors in the code before it is run, performing static analysis in real-time or within the code inspections. Larastan works in a similar way. It also allows you to check the code of different Laravel packages. Also, it supports most of Laravel’s magic methods.
One of Larastan’s features is the booting of the application’s container. This allows working with the types that can be computed only at runtime. Thus the code analysis can cover even more.
The analyzer also allows you to configure some specific rules for your project and even ignore some errors (this can be useful for some Laravel features that can be misinterpreted).
The code analysis works quite fast. The whole project can be reviewed in a single pass, and even if it contains thousands of files, it won’t take more than a few minutes. So this is a valuable tool for large projects that allows avoiding many of the issues. It checks 100% of the code allowing the developers to find the errors not covered by unit tests. It is difficult and expensive to cover all the code with unit tests, so Larastan allows to find as many flaws as possible while the developers can cover the most critical places.
The project has been in development for a long time. The oldest available release (0.4.2) became available on the project’s GitHub page back in October 2019, while some mentions were even in 2018. And this week, the stable release, v.1.0.0, became available.