SanderRonde / phpstan-vscode

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

PHPStan process exited with error, container configuration and symfony #37

Closed ljanecek closed 1 year ago

ljanecek commented 1 year ago

Hi, I can't get the plugin to work over docker and symfony project.

When I run the command with all attributes in the terminal directly, it prints correctly. docker exec -it php-fpm vendor/bin/phpstan analyse -c phpstan.neon --error-format=raw --no-interaction --memory-limit=1G --no-progress src/Model/Some.php --level max

"Language Server" are disable

My .vscode/settings.json:

{
  "phpstan.binCommand": [
    "docker exec -it php-fpm vendor/bin/phpstan"
  ],
  "phpstan.paths": {
    "/Users/xyz/Developer/xyz/backend/": ""
  },
  "phpstan.configFile": "backend/phpstan.neon",
  "phpstan.options": ["--level max"]
}

PHPStan client output in VSC:

[check:20] Spawning PHPStan with the following configuration:  {"binCmd":"docker exec -it php-fpm vendor/bin/phpstan","args":["analyse","-c","phpstan.neon","--error-format=raw","--no-interaction","--memory-limit=1G","--no-progress","--level max","src/Model/Some.php"]}
[status-bar] Hiding status bar, last operation result = Error
[check:20] Check completed for file:///Users/xyz/Developer/xyz/backend/src/Model/Some.php errors= {}
[check:20] PHPStan process exited with error  filteredErr=  rawErr=  data=  errMsg=spawn docker exec -it php-fpm vendor/bin/phpstan ENOENT

Would anyone have any idea how to find out where the problem might be? Thank you. 👍

SanderRonde commented 1 year ago

Hey, I think the issue is that binCommand is an array that should have its individual terms as array elements instead of one array item with all of them. What's going wrong is that it's taking the first array item (in this case only one) and looking up the file path (there is no match since it's a big string). An example would be {"phpstan.binCommand": ["/usr/bin/docker", "exec", "-it", "php-fpm", "vendor/bin/phpstan"]}. I'm not actually sure why I made it an array instead of just a string that is split but can't really change it now anymore unforunately. Hope this helps!

ljanecek commented 1 year ago

[check:189] PHPStan process exited succesfully It works, thanks a lot, great job!