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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With