SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
43 stars 8 forks source link

PHPStan process exited with error ... No files found to analyse #50

Closed rubinlinux closed 7 months ago

rubinlinux commented 8 months ago

If your phpstan.neon file contains an excludePaths: but you edit a file in one of those paths with vscode, you will receive an error every time you save, as phpstan is being handed the file to analyse but it has been told not to analyse that file.

For me this is the case because I do not have phpstan configured to evaluate our tests/ directory and a couple of other files which for one reason or other are not useful to have errors about.

includes:
    - phpstan-baseline.neon

parameters:
    level: 1
    paths:
     - app
     - tests
    excludePaths:
     - tests/
     - app/configs/configs-local.php
     - app/configs/db_configs-local.php
    reportUnmatchedIgnoredErrors: false
    scanDirectories:
     - lib/

In the PHPStan Client logs, after saving a file in tests/ I get this:

[check:1259] Spawning PHPStan with the following configuration:  {"binCmd":"/myproject/vendor/bin/phpstan","args":["analyse","-c","/myproject/phpstan.neon","--error-format=raw","--no-interaction","--memory-limit=1G","/myproject/tests/acceptance/StudentsCest.php","-a","/tmp/tmp-12432-q7VluTy2RMQV/autoload.php","-c","/tmp/tmp-12432-q7VluTy2RMQV/config.neon"]}
[check:1259] PHPStan process exited with error  filteredErr=! [NOTE] No files found to analyse.
[WARNING] This will cause a non-zero exit code in PHPStan 2.0.  rawErr=
 ! [NOTE] No files found to analyse.   

using phpstan 1.9.14, extension v2.2.26

It may be useful to have a config setting of excludes for this plugin; or have it read the excludes from the existing .neon file.

SanderRonde commented 8 months ago

Thanks for the clear report :). This is a bit of a known isshe that I'm pretty sure this is fixed in the pre-release version of the extension though. Can you check that out and see if that fixes it? If so I should probably release it soon.

The pre-release version works a bit differently, it runs phpstan on the whole project instead of on individual files. Should ensure it uses caching (making it faster) as well as fixing issues like this.

rubinlinux commented 7 months ago

Hi SanderRonde,

The pre-release does solve it for me. Thank you so much!