Allow multiple error formatters #3671
Closed
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.
This MR introduces the
errorFormatter.multiple
(name pending). It allows a user to specify multiple output formats.In a CI environment, you sometimes want to output to multiple tools, and a table output for the logs.
Currently that is only possible by composing multiple error formatters in your own code. When you have multiple projects with the same set up, you either need a package, or duplicated code.
In your config you could specify the following, which mean you'll use both the table and gitlab output when running PHPStan with the flag
--error-format multiple
.The second commit introduces a new parameter for the gitlab output, to allow redirecting this to a file, instead of the stdout.
This means that we can have both a table output in the logs, and a gitlab output written to a file.
I have not added this paramter to other formatters like the JSON one, as i'm unsure if this is the way to go.
With the gitlab option one could then the following configuration to output the needed json for gitlab, and still have a table output.
Another option would be change the error-format flag to allow multiple error formatters. I think this way gives users more freedom as they can specify the
multiple
as their default error formatter in the configuration.