Detect phpcs version and add option --no-patch if version 2.*#16
Open
averagegeek wants to merge 1 commit intosoderlind:masterfrom
Open
Detect phpcs version and add option --no-patch if version 2.*#16averagegeek wants to merge 1 commit intosoderlind:masterfrom
averagegeek wants to merge 1 commit intosoderlind:masterfrom
Conversation
|
I encountered the same issue, but found out that by giving an options parameter with a cwd property solves the issue. Ie: |
Author
|
Yup, you're absolutely right and it's a better solution than checking for the version. Didn't knew you could pass in the working directory that way :) |
0f31b73 to
aa3b715
Compare
the phpcbf command so reports can be generated properly and replacing the console.group() and console.groupEnd() with console.log() because those don't exists in node and trigger errors.
aa3b715 to
ff53da4
Compare
github-actions bot
added a commit
that referenced
this pull request
Mar 11, 2026
On macOS (and some Linux setups), the default process working directory can be '/' or another read-only location. phpcs 2.x tries to write a temporary diff/patch file to the current working directory during processing and fails with a permission error, making the extension non-functional. Setting cwd to TmpDir (os.tmpdir()) ensures phpcbf always runs from a writable directory, fixing the phpcs 2.x incompatibility reported in #16. The fix is minimal and surgical — no behaviour change on phpcs 3.x, where the temp file is already written to TmpDir via the fileName argument. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 11, 2026
github-actions bot
added a commit
that referenced
this pull request
Mar 19, 2026
- Fix hang on exit code 0 (nothing to fix) - closes #39 - Always close stdin to prevent timeout errors - closes #35 - Use path.join() for temp file paths (Windows compatibility) - Set cwd:TmpDir in cp.spawn for phpcs 2.x macOS compatibility - closes #16 - Fix fs.exists async race in addRootPath() → fs.existsSync - closes #36 - Fix broken phpcbfError display pattern for exit code 3 - resolve([]) instead of reject() in formatting provider - closes #19 - Read phpcbf.onsave per-document URI in onWillSaveTextDocument - closes #27 - Only reload settings on phpcbf.* config changes - Resolve ~, ./, ${workspaceFolder}/${workspaceRoot} in phpcbf.standard - closes #7, #38 - Clean up temp file on spawn error - Bump version to 0.0.10 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot
added a commit
that referenced
this pull request
Mar 25, 2026
- Fix hang when phpcbf has nothing to fix (exit code 0 → reject cleanly) - Always close stdin in format() regardless of debug mode - Use path.join() for temp file path (fixes Windows path separators) - Set cwd: TmpDir in cp.spawn (phpcs 2.x macOS compatibility, closes #16) - Fix fs.exists async race in addRootPath() → use fs.existsSync - Fix exit code 3 stdout reading (was registered after spawn, too late) - resolve([]) instead of reject() in provideDocumentFormattingEdits (closes #19) - Read phpcbf.onsave per-document URI in onWillSaveTextDocument (closes #27) - Only reload settings on phpcbf.* config changes (not all VS Code changes) - Resolve ~, ./, ${workspaceFolder}, ${workspaceRoot} in phpcbf.standard (closes #7, #38) - Clean up temp file on spawn error Closes #7, #16, #19, #27, #35, #36, #38, #39 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ran into this issue, here is a proposition for a fix:
The extension does not work with phpcs 2.* on macos (haven't tried other operating systems) at the moment because by default, phpcs tries to write a .diff file in the current working directory. On macos, php is getting
/as working directory and obviously can't write the diff file and fail with an error. Passing in the working directory when calling the phpcbf command fixes the issue.Also the file argument is now added at the very end of the arguments and the
console.group()andconsole.groupEnd()calls were replaced as those methods don't exists in node and trigger errors.