PHPStan - PHP Static Analysis Tool

(( gitHubWatchers )) (( gitHubStars )) (( gitHubForks ))

PHPStan - PHP Static Analysis Tool focuses on finding errors in your code without actually running it.

It catches whole classes of bugs even before you write tests for the code.

Installation

Install from a Composer package as a dev dependency (with Composer)

Make sure you have Composer installed.

Require it as a dev dependency:
composer require --dev phpstan/phpstan
Run it:
php vendor/bin/phpstan

Install from a PHP Archive (with curl or wget)

The PHPUnit documentation has a clear manual on how to install PHARs on Windows.

If you have the Suhosin extension enabled, make sure to allow the execution of PHARs in your php.ini:
suhosin.executor.include.whitelist = phar

Locally (X.X.X)

Download it:
wget -O phpstan-X.X.phar https://github.com/phpstan/phpstan/releases/download/X.X/phpstan-X.X.phar
or
curl -sSL https://github.com/phpstan/phpstan/releases/download/X.X/phpstan-X.X.phar -o phpstan-X.X.phar
Use it:
php phpstan-X.X.phar

Globally (X.X.X)

Download it:
wget -O phpstan-X.X.phar https://github.com/phpstan/phpstan/releases/download/X.X/phpstan-X.X.phar
or
curl -sSL https://github.com/phpstan/phpstan/releases/download/X.X/phpstan-X.X.phar -o phpstan-X.X.phar
Install it as an executable:
chmod a+x phpstan-X.X.phar
sudo mv phpstan-X.X.phar /usr/local/bin/phpstan-X.X
Use it:
phpstan-X.X