SanderRonde / phpstan-vscode

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

Cannot get v1.1.7 to work on Windows #5

Closed Balkoth closed 2 years ago

Balkoth commented 2 years ago

This is the phpstan-vscode output:

Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin","args":["analyse","-c","C:\\Temp\\global.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\functions.php"],"cwd":"c:\\Temp"}
PHPStan process exited with error, data= 
Hiding status bar, last operation result = Error
File check failed for file c:\Temp\functions.php

Running PHPStan manually from the command line works fine.

SanderRonde commented 2 years ago

Hmm weird that it's going for that temporary director. Can you do a few things for me?

Balkoth commented 2 years ago
SanderRonde commented 2 years ago

Ah I completely misunderstood the issue. I thought something was going wrong with the extension creating a temporary file but it was actually just you using it on a workspace located at C:/Temp. I think I know what the issue is and I've fixed it in version 1.2.0 (which I just published). Can you let me know if that fixed it?

Balkoth commented 2 years ago

Will check and get back to you next week.

Balkoth commented 2 years ago

Now it does not error out, but does not show problems either.

SanderRonde commented 2 years ago

When you open the output panel for PHPStan, what is logged there? Does the errors= log contain any errors or does it not log any either?

Balkoth commented 2 years ago

There is nothing after errors= in a file which has problems shown when used with PHP Static Analysis and the same configuration file.

SanderRonde commented 2 years ago

Just checking but can you run the PHPStan binary with the args that are posted in the logs? Does PHPStan output any errors then?

Balkoth commented 2 years ago

Test file:

<?php

function test($param)
{
  if (!$result)
    return 'ERROR';

  return 'OK';
}

?>

phpstan-vscode:

Document saved, checking
Checking file c:\Temp\PHPStan-vsc\functions.php
Showing status bar
Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin","args":["analyse","-c","C:\\Temp\\PHPStan-vsc\\phpstan.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\PHPStan-vsc\\functions.php"],"cwd":"c:\\Temp\\PHPStan-vsc"}
PHPStan process exited succesfully
Hiding status bar, last operation result = Success
File check done for file c:\Temp\PHPStan-vsc\functions.php errors= 
Active editor changed, checking

Running PHPStan binary from cmd:

"C:\Program Files\Composer\vendor\bin\phpstan.bat" analyse -c "C:\Temp\PHPStan-vsc\phpstan.neon" --error-format=raw --no-progress --no-interaction --memory-limit=1G "C:\Temp\PHPStan-vsc\functions.php"
C:\Temp\PHPStan-vsc\functions.php:3:Function test() has no return type specified.
C:\Temp\PHPStan-vsc\functions.php:3:Function test() has parameter $param with no type specified.
C:\Temp\PHPStan-vsc\functions.php:5:Undefined variable: $result
SanderRonde commented 2 years ago

Thanks for the info! Looks like the binPath setting is not correct. It's currently pointing to the binary folder, not the actual binary to run. Can you check if it works when you change it to be the full C:\Program Files\Composer\vendor\bin\phpstan.bat (or C:\Program Files\Composer\vendor\bin\phpstan, not sure what's right on Windows)?

Balkoth commented 2 years ago

Does not matter:

Document saved, checking
Checking file c:\Temp\PHPStan-vsc\functions.php
Showing status bar
Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin\\phpstan.bat","args":["analyse","-c","C:\\Work\\Config\\phpstan.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\PHPStan-vsc\\functions.php"],"cwd":"c:\\Temp\\PHPStan-vsc"}
PHPStan process exited succesfully
Hiding status bar, last operation result = Success
File check done for file c:\Temp\PHPStan-vsc\functions.php errors= 
Document saved, checking
Checking file c:\Temp\PHPStan-vsc\functions.php
Showing status bar
Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin\\phpstan","args":["analyse","-c","C:\\Work\\Config\\phpstan.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\PHPStan-vsc\\functions.php"],"cwd":"c:\\Temp\\PHPStan-vsc"}
PHPStan process exited succesfully
Hiding status bar, last operation result = Success
File check done for file c:\Temp\PHPStan-vsc\functions.php errors= 
SanderRonde commented 2 years ago

Hmm I'm getting no issues when trying out that configuration (as far as I can replicate it). Can you send me these things:

Balkoth commented 2 years ago

As requested: PHPStan-vsc.zip

"phpstan.binPath": "C:\\Program Files\\Composer\\vendor\\bin\\phpstan.bat",
"phpstan.configFile": "C:\\Temp\\PHPStan-vsc\\phpstan.neon"

image

SanderRonde commented 2 years ago

I tried your exact setup but it worked fine for me so I'm really not sure what's going on here. Can you try installing this version of the extension and showing me the new logs? It's got some more logging in it. Simply rename it from .zip to .vsix and drag it into your extensions pane (github doesn't allow uploading of .vsix files). phpstan-vscode-1.2.1.zip

Balkoth commented 2 years ago

Yes, this version helped identifying the issue:

Document saved, checking
Checking file c:\Temp\PHPStan-vsc\functions.php
Showing status bar
Spawning PHPStan with the following configuration:  {"binPath":"C:\\Program Files\\Composer\\vendor\\bin\\phpstan.bat","args":["analyse","-c","C:\\Temp\\PHPStan-vsc\\phpstan.neon","--error-format=raw","--no-progress","--no-interaction","--memory-limit=1G","c:\\Temp\\PHPStan-vsc\\functions.php"],"cwd":"c:\\Temp\\PHPStan-vsc"}
Got data Der Befehl "C:\Program" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

All data received= Der Befehl "C:\Program" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

PHPStan process exited succesfully
Hiding status bar, last operation result = Success
File check done for file c:\Temp\PHPStan-vsc\functions.php errors= 
Got data Der Befehl "C:\Program" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

So there is an issue when binPath contains spaces. If i change this to a path with no spaces it works!

SanderRonde commented 2 years ago

Ah classic error. Will fix it in a bit