vscode-phpsab icon indicating copy to clipboard operation
vscode-phpsab copied to clipboard

The file gets emptied when PHP is not available on the PATH variable.

Open yCodeTech opened this issue 10 months ago • 0 comments

While a quick fix for #57 in PR #58 was merged, the file still gets emptied when PHPCBF can't find PHP in the PATH environment variable, as reported in the returned fixer object:

stderr = "'php' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

When this issue happens, the stdout is an empty string, and when the extension adds \n to it: let fixed = stdout + '\n'; the text is no longer an empty string and the length is no longer 0, therefore the check for text length if (text.length > 0) always returns true and the file gets emptied. This is solved by merging PR #142 to remove the newline at the end of the fixed code.

This only solves the emptying the document issue, and not the 'php' is not recognized issue (which I have a solution for in PR #157 ).

yCodeTech avatar Jan 23 '25 10:01 yCodeTech