Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yCodeTech opened this issue Jan 23, 2025 · 0 comments
Open

Comments

@yCodeTech
Copy link

yCodeTech commented Jan 23, 2025

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 ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant