I’m in the process of updating an old PHP application from version 5.6 to 8.3. When I run PHP_CodeSniffer, the output is overwhelming, with millions of errors, many of which are related to formatting and readability (e.g., “don’t use tabs, use spaces”). My main objective is to identify only the critical errors that will break the application, not to fix every formatting issue.
Problem:
- The error report contains an excessive number of lines, including many duplicates and non-critical readability errors.
- I need a way to exclude these non-critical errors and focus solely on the critical issues that will impact the app’s functionality in PHP 8.3.
Requirements:
- Exclude Non-Critical Errors: I want to filter out formatting and readability issues from the report.
- Deduplicate Errors: I need to ensure that duplicate errors across files are excluded from the output.
- Error Type Summary: Ideally, I want a summary that lists the types of critical errors along with the files they occur in.
What I’ve Tried:
- Running PHP_CodeSniffer without any custom rulesets, but the output is still cluttered with non-critical issues.
- Attempting to use regex to filter the output manually, but this approach is not feasible for the volume of errors.
I tried this but it didn’t work
/root/vendor/bin/phpcs /path/to --error-severity=1 --warning-severity=0 --standard=PSR12 --report=full > phpcs_output.txt
Question:
How can I configure PHP_CodeSniffer to generate a report that focuses exclusively on critical errors for PHP 8.3 migration, excluding duplicates and non-critical readability issues?
Any tips or scripts that can help automate this process would be greatly appreciated!