SanderRonde / phpstan-vscode

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

Unable to use variable ${workspaceFolder} in phpstan.paths #56

Closed yonailo closed 4 months ago

yonailo commented 4 months ago

Hello,

I am trying to use phpstan extension through lando, this is my configuration:

    "phpstan.binCommand": [
        "/usr/local/bin/lando_phpstan"
    ],
    "phpstan.paths": {
        "${workspaceFolder}": "/app/"
    },
    "phpstan.configFile": "phpstan.neon",
    "phpstan.enableLanguageServer": false

But the $workspaceFolder seems to not work, as I see in the debug output :

[check:9] Spawning PHPStan with the following configuration:  {"binCmd":"/usr/local/bin/lando_phpstan","args":["analyse","-c","/home/juan/Projects/xxx/phpstan.neon","--error-format=raw","--no-interaction","--memory-limit=1G","--no-progress","/home/juan/Projects/xxx/web/modules/custom/xxx_global/src/Plugin/QueueWorker/NotificationEmailQueueWorker.php"]}
[check:9] PHPStan process exited succesfully

On the other hand, if I replace ${workspaceFolder} by the real fullpath, everything works as expected.

Can you help me ? Thank you in advance.

SanderRonde commented 4 months ago

Does it work if you use a relative path? So just ". /"?

yonailo commented 4 months ago

No it does not seem to work:


client] Starting extension with configuration: {
    "binPath": "vendor/bin/phpstan",
    "binCommand": [
        "/usr/local/bin/lando_phpstan"
    ],
    "configFile": "phpstan.neon",
    "rootDir": "",
    "options": [],
    "enableStatusBar": true,
    "memoryLimit": "1G",
    "enabled": true,
    "timeout": 10000,
    "projectTimeout": 60000,
    "suppressTimeoutMessage": false,
    "paths": {
        "./": "/app/"
    },
    "showProgress": false,
    "enableLanguageServer": false,
    "ignoreErrors": [],
    "suppressWorkspaceMessage": false
}
[client] Initializing done
[server] Language server ready
[server] Language server started
[file-watcher] Document active, checking
[check:1] Check started for file:///home/juan/Projects/xxx/web/modules/custom/xxx/xxx.module
[status-bar] Showing status bar
[check:1] Spawning PHPStan with the following configuration:  {"binCmd":"/usr/local/bin/lando_phpstan","args":["analyse","-c","/home/juan/Projects/xxx/phpstan.neon","--error-format=raw","--no-interaction","--memory-limit=1G","--no-progress","/home/juan/Projects/xxx/web/modules/custom/xxx/xxx.module"]}
[server] PHPStan version: PHPStan - PHP Static Analysis Tool 1.10.58

[check:1] PHPStan process exited succesfully
[status-bar] Hiding status bar, last operation result = Success
[check:1] Check completed for file:///home/juan/Projects/xxx/web/modules/custom/xxx/xxx.module errors= {"file:///home/juan/Projects/xxx/web/modules/custom/xxxx/xxx.module":[]}
SanderRonde commented 4 months ago

Should be fixed on master. I'll let you know when I'm releasing a new version so you can give it a test :)

stefanfisk commented 1 month ago

@SanderRonde I just encountered this issue. AFAICT ${workspaceFolder} does not work but specifying the absolute path does.

SanderRonde commented 1 month ago

Are you sure? Could it maybe be the case that the workspaceFolder is not the same as the absolute path? When I test this it does seem to work

stefanfisk commented 3 weeks ago

@SanderRonde I was using workspaceRoot out of old habits. workspaceFolder worked!