Conversation
As of PHPCS 3.13.0, PHPCS will show deprecation notices for various features which will be removed in PHPCS 4.0.0.
However, in PHPCS 3.x, PHPCS sends all output to `STDOUT` (this will change in PHPCS 4.x), so if the output of an `exec` command which expects a `json` report is captured, this will now also include the deprecation notices in the output, which means the `json_decode()` command will fail as the captured output is not valid JSON.
This, in turn, is currently causing the Ruleset test runs to fail in CI for the VIPCS repo. The issue is locally reproducable.
This commit fixes this by:
* Changing the `--report=json` in the command being run to `--report-json=[filename]` and storing the JSON output to a file.
This way the report file will _only_ contain report output and will not include the deprecation notices (those will still go to `STDOUT`).
* Next, we read the report file to process the JSON report;
* And then delete the report file (and prevent it from being committed via the `.gitignore` file, just in case the file delete would fail at some point).
This solution is PHPCS cross-version compatible as the `--report-json=[filename]` CLI flag has been around for quite a while.
This solution should also improve the stability of the script for potential future changes in PHPCS.
GaryJones
approved these changes
May 20, 2025
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.
As of PHPCS 3.13.0, PHPCS will show deprecation notices for various features which will be removed in PHPCS 4.0.0.
However, in PHPCS 3.x, PHPCS sends all output to
STDOUT(this will change in PHPCS 4.x), so if the output of anexeccommand which expects ajsonreport is captured, this will now also include the deprecation notices in the output, which means thejson_decode()command will fail as the captured output is not valid JSON.This, in turn, is currently causing the Ruleset test runs to fail in CI for the VIPCS repo. The issue is locally reproducable.
This commit fixes this by:
--report=jsonin the command being run to--report-json=[filename]and storing the JSON output to a file. This way the report file will only contain report output and will not include the deprecation notices (those will still go toSTDOUT)..gitignorefile, just in case the file delete would fail at some point).This solution is PHPCS cross-version compatible as the
--report-json=[filename]CLI flag has been around for quite a while.This solution should also improve the stability of the script for potential future changes in PHPCS.