phpstan-vscode icon indicating copy to clipboard operation
phpstan-vscode copied to clipboard

Unhandled method phpstan.configResolve

Open antero111 opened this issue 3 months ago • 7 comments

Hello.

I get following error when starting vscode with the extension enabled. This causes the inline errors or problem view listing to not show up.

Unhandled method phpstan.configResolve
    at Oe (/home/user/.vscode-server/extensions/sanderronde.phpstan-vscode-4.0.9/out/extension.js:4:233)
    at ue (/home/user/.vscode-server/extensions/sanderronde.phpstan-vscode-4.0.9/out/extension.js:3:7388)
    at se (/home/user/.vscode-server/extensions/sanderronde.phpstan-vscode-4.0.9/out/extension.js:3:7511)
    at Immediate.<anonymous> (/home/user/.vscode-server/extensions/sanderronde.phpstan-vscode-4.0.9/out/extension.js:3:7275)
    at processImmediate (node:internal/timers:485:21)

phpstan.neon config:

parameters:
    level: 1
    paths:
        - app
        - tests
    excludePaths:
        - app/Policies

The analysis runs fine according to the phpstan output window but the error can be seen in Extension Host (remote) window.

Startup parameters:

[10/31/2025, 11:37:07 AM] [client] Starting extension with configuration: {
	"phpstan.singleFileMode": false,
	"phpstan.binPath": "vendor/bin/phpstan",
	"phpstan.binCommand": [],
	"phpstan.configFile": "phpstan.neon",
	"phpstan.paths": {},
	"phpstan.dockerContainerName": "",
	"phpstan.rootDir": "",
	"phpstan.options": [],
	"phpstan.enableStatusBar": true,
	"phpstan.memoryLimit": "1G",
	"phpstan.enabled": true,
	"phpstan.projectTimeout": 300000,
	"phpstan.timeout": 300000,
	"phpstan.suppressTimeoutMessage": false,
	"phpstan.showProgress": true,
	"phpstan.showTypeOnHover": true,
	"phpstan.enableLanguageServer": false,
	"phpstan.ignoreErrors": [
		"Xdebug: .*"
	],
	"phpstan.suppressWorkspaceMessage": false,
	"phpstan.pro": false,
	"phpstan.tmpDir": "",
	"phpstan.checkValidity": true
}
[10/31/2025, 11:37:07 AM] [client] Initializing done
[10/31/2025, 11:37:07 AM] [client] Showing one-time messages (if needed)
[10/31/2025, 11:37:07 AM] [server] Language server ready
[10/31/2025, 11:37:07 AM] [server] Language server started

I have autosave on and check validity setting enabled.

Interesting thing is that after manually saving some file, the analysis is done again and then the inline errors show up. It seems that there might be issues with the extension startup!

Overall this does not halt my extension usage but causes small inconvenience when the analysis seems to be OK when staring vscode but after some typing (automatic file save), errors show up.

ie: Opening vscode > navigatge to file > "All seems OK". > write code --> Old errors show up.

OS: WSL2 ubuntu with Laravel Sail Docker environment.

Ext v4.0.9

phpstan v2.1.31

Thanks in advance!

antero111 avatar Oct 31 '25 09:10 antero111

Ah yeah I'm fairly sure this is related to the extension performing actions before the language server is completely ready. I've changed it so that it waits until everything is ready :)

SanderRonde avatar Oct 31 '25 09:10 SanderRonde

Thank you for the super fast fix! Error is now fixed and I suppose this works now correctly. One thing to note that the problems tab and highlights are only shown after file save. I noticed this:

[info] ExtensionService#_doActivateExtension SanderRonde.phpstan-vscode, startup: false, activationEvent: 'onLanguage:php'

Have you tried to enable the extension to run on startup so that the errors would be available right away on startup?

antero111 avatar Oct 31 '25 10:10 antero111

I did consider that but VSCode very much so discourages that (link). A big downside would be that it would also start this extension when you're working on a non-PHP project, which can be quite annoying if it's only a language you (let's say) work on 50% of the time.

SanderRonde avatar Oct 31 '25 10:10 SanderRonde

Fair enough. Maybe I can live with one quick save before the analysis. Thanks for the response.

antero111 avatar Oct 31 '25 10:10 antero111

Hmm it should automatically analyze on-startup too. The extension will activate when you open a PHP file. Does that not work?

SanderRonde avatar Oct 31 '25 10:10 SanderRonde

Yes it does as seen from the output window but inline highlights are now shown and the problem view is not populated.

[10/31/2025, 12:59:40 PM] [client] Starting extension with configuration: {
	"phpstan.singleFileMode": false,
	"phpstan.binPath": "vendor/bin/phpstan",
	"phpstan.binCommand": [],
	"phpstan.configFile": "phpstan.neon",
	"phpstan.paths": {},
	"phpstan.dockerContainerName": "",
	"phpstan.rootDir": "",
	"phpstan.options": [],
	"phpstan.enableStatusBar": true,
	"phpstan.memoryLimit": "1G",
	"phpstan.enabled": true,
	"phpstan.projectTimeout": 300000,
	"phpstan.timeout": 300000,
	"phpstan.suppressTimeoutMessage": false,
	"phpstan.showProgress": true,
	"phpstan.showTypeOnHover": true,
	"phpstan.enableLanguageServer": false,
	"phpstan.ignoreErrors": [
		"Xdebug: .*"
	],
	"phpstan.suppressWorkspaceMessage": false,
	"phpstan.pro": false,
	"phpstan.tmpDir": "",
	"phpstan.checkValidity": true
}
[10/31/2025, 12:59:40 PM] [client] Initializing done
[10/31/2025, 12:59:40 PM] [client] Showing one-time messages (if needed)
[10/31/2025, 12:59:40 PM] [server] Language server ready
[10/31/2025, 12:59:40 PM] [server] Language server started
[10/31/2025, 12:59:41 PM] [file-watcher] Checking: New document active
[10/31/2025, 12:59:41 PM] [check:1] Check started for project
[10/31/2025, 12:59:41 PM] [status-bar] notification:' {"opId":0,"type":"new","tooltip":"Checking project"}
[10/31/2025, 12:59:41 PM] [status-bar] Showing status bar
[10/31/2025, 12:59:41 PM] [server] PHPStan version: PHPStan - PHP Static Analysis Tool 2.1.31

[10/31/2025, 12:59:41 PM] [check:1] Spawning PHPStan with the following configuration:  ...
[10/31/2025, 12:59:41 PM] [check:1] Spawning PHPStan, command:  /home/user/project/vendor/bin/phpstan "analyse" "-c" "/home/user/project/phpstan.neon" "--error-format=json" "--no-interaction" "--memory-limit=1G" "-a" "/home/user/.vscode-server/extensions/sanderronde.phpstan-vscode-4.0.10/_config/a499dae16d91797b7a71de06920b8a4a/autoload.php" "-c" "/home/user/.vscode-server/extensions/sanderronde.phpstan-vscode-4.0.10/_config/a499dae16d91797b7a71de06920b8a4a/config.neon"
[10/31/2025, 12:59:41 PM] [process-spawner] Spawning process 25278 with timeout 900000
[10/31/2025, 12:59:42 PM] [status-bar] notification:' {"progress":{"done":0,"total":238,"percentage":0},"opId":0,"type":"progress","tooltip":"Checking project - 0/238 (0%)"}
[10/31/2025, 12:59:42 PM] [status-bar] notification:' {"progress":{"done":238,"total":238,"percentage":100},"opId":0,"type":"progress","tooltip":"Checking project - 238/238 (100%)"}
[10/31/2025, 12:59:42 PM] [check:1] PHPStan process exited succesfully
[10/31/2025, 12:59:42 PM] [status-bar] notification:' {"opId":0,"result":"Success","type":"done"}
[10/31/2025, 12:59:42 PM] [status-bar] Hiding status bar, last operation result = Success

Highlights only appear after manual ctrl+s on a php file.

antero111 avatar Oct 31 '25 11:10 antero111

Ah that shouldn't be the case, will take a look at that then

SanderRonde avatar Oct 31 '25 11:10 SanderRonde