SanderRonde / phpstan-vscode

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

Extension errors due to bad temp file paths on windows #14

Closed Blasio closed 1 year ago

Blasio commented 2 years ago

The extension errors every time a file is saved. In the PHP error log file the error message is:

PHP Fatal error: require_once(): Failed opening required 'C:\Users\user\AppData\Local\Temp mp-5052-JlXbXoybU6M6\TreeFetcher.php' (include_path='.;C:\php\pear') in C:\Users\user\AppData\Local\Temp\tmp-5052-JlXbXoybU6M6\autoload.php on line 2

The problem seems to be that the \t in ...Temp\tmp-5050... is getting converted to an actual tab character. I have gotten the extension to work by changing

h+=`require_once "${i}";
`),h+=`require_once "${o}";

to

h+=`require_once '${i}';
`),h+=`require_once '${o}';

but I'm not sure if that is breaking other things as now clicking a problem in the list no longer takes me to the actual file and instead I get an error saying the resource cannot be loaded.

In the second error I see that instead of a \ or / as path separator, there's %5C, which seems to be an encoding of \ so maybe there's also an issue related to encoding somewhere in there.

SanderRonde commented 1 year ago

Thanks for reporting these issues! I'm pretty sure I've nailed them both down. The first one was an easy fix thanks to your suggestion, the second one had to do with file paths not being parsed correctly on windows. Should be fixed in the next release.