sajad torkamani

In a nutshell

PHPStan is a linter for PHP, similar to ESLint for JavaScript.

Install

composer require --dev phpstan/phpstan

Analyse using config file

Ensure you have a phpstan.neon or phpstan.neon.dist file and run:

vendor/bin/phpstan

Create config file (phpstan.neon)

Minimal config file:

parameters:
	level: 9
	paths:
		- src
		- tests

Analyse with default rule (0)

vendor/bin/phpstan analyse <directories>

Analyse with specific rule

vendor/bin/phpstan analyse -l <0-9> directories

Configure rules

You can choose a level from 0 to 9 (0 is the loosest and 9 is the highest):

Add more strictness

Install the phpstan/phpstan-strict-rules package: