Closed Grldk closed 2 weeks ago
Did my changes in that issue not fix the problem? I thought I had fixed it. If not I'll look into it again.
Ah sorry, maybe should have reacted in that issue. Looks like I'm still getting the same error:
TypeError: e.replace is not a function
at Dt (/var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.1.4/out/server.js:74:2725)
at /var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.1.4/out/server.js:74:2689
at Array.map (<anonymous>)
at le (/var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.1.4/out/server.js:74:2635)
at async gP (/var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.1.4/out/server.js:79:11839)
Ah I've figured it out. The issue is that the setting you posted is not valid JSON. Regex in JSON isn't supported (you'll probably notice how github and VSCode mark it as red). What VSCode does is that it tries to parse it to the best of its ability, and when it sees the [
it turns it into an empty array. So effectively your setting is phpstan.ignoreErrors: [[], []]
, which then leads to an issue when my extension expects a string or RegExp.
It should work again if you just replace it with "phpstan.ignoreErrors": [ "! [NOTE] No files found to analyse. [WARNING] This will cause a non-zero exit code in PHPStan 2.0. " ],
My extension still does parse the string as regex, so things like .*
will still work. Also since it's treated as a regex you can just do "phpstan.ignoreErrors": ["No files found to analyse"]
and it should also work since the error contains the to-ignore value you specified (it doesn't need to be an exact match).
I can't seem to be able to ignore that error in any way. I tried your suggestions but they still lead to the extension erroring out.
My bad, since it's actually two separate errors (one NOTE and one WARNING), both need to be ignored. You'll notice that err=
will no longer contain the NOTE but will still contain the WARNING. To fix this, ignore both, so:
"phpstan.ignoreErrors": ["No files found to analyse", "This will cause a non-zero exit code in"],
Hmm. I should have noticed that there were two errors... Trying that suggestion returns another error though:
[check:1] PHPStan process exited succesfully
undefined:1
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at ChildProcess.<anonymous> (/var/www/.vscode-server/extensions/sanderronde.phpstan-vscode-3.1.4/out/server.js:76:1595)
Node.js v18.18.2
[Info - 2:45:21 PM] Connection to server got closed. Server will restart.
true
Ahh what's happening is that I'm giving the output-mode=json
to PHPStan and because of the error it's not outputting anything, which makes the JSON parse fail. I'll make it so that, if any errors were ignored, this error does not cause a check to fail. But it does seem iffy to just ignore PHPStan exiting with an actual error (not just a warning).
Can you check whether the below version fixes the issue?
if any errors were ignored, this error does not cause a check to fail. But it does seem iffy to just ignore PHPStan exiting with an actual error (not just a warning).
Yeah that's part of why I actually made a separate issue. I was wondering if it's possible to handle this error separately so you don't ignore unexpected errors..
Can you check whether the below version fixes the issue?
Will try later today or tomorrow.
Thanks!
Yeah good point. I actually had hoped that the move to full-project scans would fix this issue since that way PHPStan only includes the relevant files. But I think you're actually right that this should be handled separately, especially since the extension is (unless manually triggered) the one triggering the checking. I'll do that instead. (you can skip checking the package I posted before, I'll throw away that fix and go for an automatic ignore).
I've fixed the issue in https://github.com/SanderRonde/phpstan-vscode/commit/65064610b99af5fa45f1428f071c3a19f886cc05. That version is live now, can you let me know if it works?
Issues go stale after too much time without activity. If inactive for another 7 days this issue will be closed.
Hey I'll just mark this as fixed since I did ship the fix. Feel free to re-open if it wasn't fixed.
We have a couple of folders that are ignored by phpstan (through the excludePaths config in phpstan.neon.dist). If I run this extension in single file mode and scan a file in one of these folders phpstan exits with an error (copy/pasted from the output log):
This causes the plugin to error out as well.
Previously I had a regex in
phpstan.ignoreErrors
to ignore this (only way I found to ignore this error...), but this doesn't work anymore inv3
. (see https://github.com/SanderRonde/phpstan-vscode/issues/70).So what I'd like is either to use a regex in ignoreErrors again, or for the plugin to exit without an error in this scenario...