Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStan, exclude all and specify files to check

Tags:

phpstan

Im trying to setup PHPStan on a older, bigger, codebase. How could i exclude everything and than maybe by config define what to analyse.

I have thought about using a separate folder for it, but that would mean constantly moving files which might lead to breaking of the code. So i am hoping to exclude everything and then adding files to the analysers per file.

At this moment the only solution i was able to find is defining a script in composer.json

  "scripts": {
    "phpstan": "./vendor/bin/phpstan analyse --memory-limit=1G --no-progress --level 1 `cat phpstan_analyse_files`"
  }

And keeping a list of files to analyise in the file phpstan_analyse_files

like image 353
Michal Avatar asked Jul 14 '18 07:07

Michal


1 Answers

The best way to do what you need is excludePaths section as of PHPStan 1.0:

# phpstan.neon
parameters:
    excludePaths:
        - 'old-code/OldClass.php'
        - 'another-old-code/*'

See docs or this real project phpstan.neon setup for inspiration.

like image 84
Tomas Votruba Avatar answered Sep 22 '22 02:09

Tomas Votruba