SanderRonde / phpstan-vscode

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

[3.0.7] Crashes on startup #70

Closed Grldk closed 2 months ago

Grldk commented 2 months ago

VS Code just updated the phpstan plugin to 3.0.7, this version crashes on startup with this error:

TypeError: e.replace is not a function
    at Ft (/var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.0.7/out/server.js:74:2674)
    at /var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.0.7/out/server.js:74:2638
    at Array.map (<anonymous>)
    at me (/var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.0.7/out/server.js:74:2631)
    at async kP (/var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.0.7/out/server.js:79:16880)

Node.js v18.18.2

Not sure whats going on.. It crashes on every php file I open.

SanderRonde commented 2 months ago

It looks like this means the config.ignoreErrors setting contains non-string values. Could that be the case? That might help me find the fix.

Grldk commented 2 months ago

Yeah that seems to be the problem. I had this:

    "phpstan.ignoreErrors": [
        /! [NOTE] No files found to analyse.
[WARNING] This will cause a non-zero exit code in PHPStan 2.0.  /
    ],

Because I had some problems in the past where phpstan-vscode didn't handle files in the excludePaths list in phpstan.neon.dist correctly. If I remove that config the plugin works again. Seems that the line isnt necessary anymore anyway. Thanks!

SanderRonde commented 2 months ago

Ahh I didn't know VSCode would interpret those as regular expressions instead of strings, will ensure this is fixed in the extension too so it won't happen in the future either. But good to know this fixes it, thanks!

HomelessCoder commented 2 months ago

@SanderRonde Hi! Many thanks for your work on the extension! After the latest update from 2.2.26 to 3.0.7, my setup broke. Now it crashes with:

[check:1] PHPStan process exited with error  filteredErr=At least one path must be specified to analyse.  rawErr=At least one path must be specified to analyse.
  data=

As far as I understand, this is due to the absence of the "paths" in the phpstan.neon, and the operating mode between the 2 and 3 versions differs: in the latter, it's always "project" mode.

Would it be possible to allow a "single file" mode in v3? The project I'm working on is quite old and contains millions of files. It works with the "paths", but I literally can't do things when it checks the entire folder on save :(

PS. Oh, it seems I'm late to the issue while writing the comment :D

SanderRonde commented 2 months ago

Hmm I'll consider supporting it but it will depend on how much work it is to have the two versions coexist. I'll get back to you on that!

In the meantime you can right-click the extension and choose "install another version" to go back to the 2.0 version that still had file-checks.

HomelessCoder commented 2 months ago

Thank you! Yes, I rolled back to 2.2.26, and it works =)

SanderRonde commented 2 months ago

Hey @HomelessCoder I've added support for it again. You can enable it using the phpstan.singleFileMode setting. Or alternatively it'll warn you about that setting's existence if the "At least one path must be specified to analyze" errors is encountered. It should be live now in version 3.1.0. Let me know if it works :)

HomelessCoder commented 2 months ago

@SanderRonde Omg! I didn't expect such an instant fix, but that just works! :heart_eyes: Thank you!