-
-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Describe the bug
If you run with the --report=json flag, deprecation warnings are printed out first in plain text, then the json output follows. A major use case for the JSON report is to have reliably parsable output, which this breaks.
Reported originally at SublimeLinter/SublimeLinter-phpcs#59
Code sample
Any code that triggers sniff that are deprecated for 4.0. I'm sorry, I don't have a case at hand currently.
Custom ruleset
None.
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.phpwith the code sample above... - Run
phpcs --report=json -s test.php - See error message displayed
WARNING: The WordPress standard uses 1 deprecated sniff
-------------------------------------------------------------------------------
- Generic.Functions.CallTimePassByReference
This sniff has been deprecated since v3.12.1 and will be removed in v4.0.0.
Deprecated sniffs are still run, but will stop working at some point in the
future.
{"totals":{"errors":1,"warnings":1,"fixable":2},"files":{ (... JSON snipped)
Expected behavior
Deprecation warnings should perhaps be grouped under the warnings in the JSON output. Or a flag might be introduced to silence deprecation warnings.
Versions (please complete the following information)
| Operating System | MacOS 15.5 |
| PHP version | 8.4.6 |
| PHP_CodeSniffer version | 3.13.2 |
| Standard | PSR12 |
| Install type | Composer local |
Additional context
We're using the JSON output to be able to parse it and present it in the context of the SublimeLinter plugin for Sublime Text. I'm a maintainer of said plugin, and use phpcs daily in that mode (but haven't run into the problem myself yet).
Please confirm
- I have searched the issue list and am not opening a duplicate issue.
- I have read the Contribution Guidelines and this is not a support question.
- I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
- I have verified the issue still exists in the
masterbranch of PHP_CodeSniffer.