As mentioned in https://github.com/Symplify/Symplify/issues/1095#issuecomment-420994905 it is possible to add different output formatters to ECS.
I would like to try and implement this feature when I have more free time. Posting this as a _TODO_ note to myself.
My main goal is to add better output to azdanov/vscode-easy-coding-standard extension.
If anyone else wants to try and implement this, it would be awesome.
Is this still relevant?
Can't find any spare time to get this done. Maybe in the future.
Closing.
No troubles mate. Thanks for update :+1:
I will start working on this feature now.
@TomasVotruba How would I go about adding a --json flag? Here are some thoughts.
1) Right now I'm thinking of duplicating and changing these lines to allow a json option:
https://github.com/Symplify/Symplify/blob/7ab3f5435d581923e290c557112e12b9cca35529/packages/EasyCodingStandard/src/Console/Command/CheckCommand.php#L63-L68
https://github.com/Symplify/Symplify/blob/7ab3f5435d581923e290c557112e12b9cca35529/packages/EasyCodingStandard/packages/Configuration/src/Option.php#L32-L35
https://github.com/Symplify/Symplify/blob/7ab3f5435d581923e290c557112e12b9cca35529/packages/EasyCodingStandard/packages/Configuration/src/Configuration.php#L26-L29
https://github.com/Symplify/Symplify/blob/7ab3f5435d581923e290c557112e12b9cca35529/packages/EasyCodingStandard/packages/Configuration/src/Configuration.php#L78-L81
2) Extract a common interface from EasyCodingStandard/src/Console/Output/CheckCommandReporter.php to EasyCodingStandard/src/Contract/Console/Output/CheckCommandReporterInterface.php.
3) Rename CheckCommandReporter.php to TableCheckCommandReporter.php.
4) Implement JsonCheckCommandReporter.php.
I'm not quite sure yet where the decision between Table and Json reporter should be done.
Either here in the constructor:
https://github.com/Symplify/Symplify/blob/7ab3f5435d581923e290c557112e12b9cca35529/packages/EasyCodingStandard/src/Console/Command/CheckCommand.php#L34-L44
Or somewhere else beforehand. Need to do more research.
Why --json? What is the option name in PHPUnit? I thought it's --error-format=xy.
1) seems ok, just differnt name, ERROR_FORMAT_OPTION and JSON_ERROR_FORMAT, TABLE_ERROR_FORMAT
2) I'd extract ErrorFormatterInterface to keep the naming consistent
3) To TableErrorFormatter
4) Add JsonErrorFormatter
Apart naming, I like your plan :+1:
I'm not quite sure yet where the decision between Table and Json reporter should be done.
Configuration is resolved form Input here:
Thanks for the feedback.
As for the --json I wasn't sure which to choose.
PHP_CS_FIXER uses --format json, PHP_CodeSniffer has --report json, PHPUnit has several log formats --log-junit, --log-teamcity and PHPStan --error-format=raw.
I do like PHPStan way of logging.
Alson eed to find out in what structure should json be. Probably some combination of PHPStan, PHPUnit, PHP_CS_FIXER and PHP_CodeSniffer, to find out which suits the best.
In the end, I'd like to use this json output for my plugin to get a better console output, and line/block highlighting for errors.
Closed by #1229