SanderRonde / phpstan-vscode

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

PHPStan checking status, but no output #45

Closed wallacio closed 9 months ago

wallacio commented 11 months ago

TLDR; make sure the extension has access to a valid PHP executable, and is executing phpstan in a way that makes sense to VSCode.

It's taken me a while to work out what's going wrong with my local environment, but for the benefit of future me and others:

Current config/use:

Extension version: pre-release (3.0.1?). The 'current' release didn't work at all - PHPStan binary couldn't be found (which is essentially the source of the problem).

Using VSCode on W11. The code repository is managed by Composer and phpstan/phpstan installed as require-dev in the project. The dev environment runs in Homestead, and a native PHP8 binary is available to VSCode in Windows to keep VSCode happy with linting etc. (I'm using Intelephense quite happily). composer install is run from a shell in Homestead, so that paths/permissions work.

I can run phpstan happily via command in either WSL or Homestead with vendor/bin/phpstan analyse. There is a phpstan.neon in the project root. The phpstan scripts (phpstan and phpstan.phar) in vendor/bin are PHP (rather than binaries).

VSCode loads the extension, but this is what's show in the status bar: image followed by image

Output from 1-PHPStan Client.log:

[client] Starting extension with configuration: {
    "binPath": "vendor/bin/phpstan",
    "binCommand": [],
    "configFile": "phpstan.neon",
    "rootDir": "",
    "options": [],
    "enableStatusBar": true,
    "memoryLimit": "1G",
    "enabled": true,
    "projectTimeout": 300000,
    "suppressTimeoutMessage": false,
    "paths": {},
    "showProgress": false,
    "enableLanguageServer": true,
    "ignoreErrors": [],
    "suppressWorkspaceMessage": false,
    "pro": false,
    "proTmpDir": ""
}
[client] Initializing done
[client] Showing one-time messages (if needed)
[server] Language server ready
[server] Language server started
[check:1] Check started for project
[status-bar] Showing status bar
[file-watcher] New document active (file:///f%3A/..../src/OCA/OcaViewPeople.php), triggering
[fixer-manager] No file changes, not checking
[file-watcher] New document active (file:///f%3A/..../src/OcaAPI/Controllers/OcaMembershipRecordsController.php), triggering
[fixer-manager] No file changes, not checking

This suggests that the extension is trying to do something, but actually it isn't.

After applying a bit of common sense I realise that VSCode has no idea what my dev environment looks like. Changing the phpstan.binCommand in settings to use the locally installed PHP binary, e.g. C:\PHP\php.exe vendor\bin\phpstan has brought it to life. Hurrah.

SanderRonde commented 11 months ago

Thanks for the report and sorry for the slow response. I don't know if I fully understand the problem here so I'll ask for some clarification.

github-actions[bot] commented 9 months ago

Issues go stale after too much time without activity. If inactive for another 7 days this issue will be closed.