Larastan v1.0 Released

https://laravelnews.imgix.net/images/larastan.png?ixlib=php-3.3.1

After initially writing about Larastan back in 2018, we are pleased to see the release of Larastan v1.0 this week, a package to help analyze Laravel application code:

Larastan is a development dependency that adds static analysis to Laravel, improving developer productivity and code quality. At the core, it’s a PHPStan wrapper for Laravel and helps you find errors in your code through static analysis. It helps catch bugs before you even write tests for the code:

  • Adds static typing to Laravel to improve developer productivity and code quality
  • Supports most of Laravel’s beautiful magic
  • Discovers bugs in your code without running it

You can use Larastan to analyze application code as well as use it to analyze your Laravel packages.

Getting started in your new or existing Laravel project is as easy as installing the package and configuring PHPStan:

1composer require nunomaduro/larastan --with-dependencies --dev

2 

3# after setting up a `phpstan.neon` file in the root

4# of your project, you can analyze your code:

5./vendor/bin/phpstan analyse

If you find this package useful, consider sponsoring the developers Nuno Maduro and Can Vural on GitHub. The Larastan project page has links to all the ways you can sponsor their work.

You can learn more about this package, get full installation instructions, and view the source code on GitHub. I’d recommend checking out the rules specific to Laravel applications, with configurable options.


You can see the complete list of new features and updates below and the diff between v0.7.15 and v1.0.0. Also, the following release notes are directly from the changelog:

v1.0.0

Added

  • Dynamic method return type extension for Enumerable::filter in #981
  • New rule to check for relation existence in #985
  • rescue parameter of rescue function now accepts the Throwable by @sebdesign in #989
  • New CheckJobDispatchArgumentTypesCompatibleWithClassConstructorRule rule in #991
  • Added non-empty-string types in stubs. c5b81cf

Fixed

  • PHPStan 1.0 compatibility in #968

Laravel News