-
-
Notifications
You must be signed in to change notification settings - Fork 884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce CLI argument to read the full analysis result as JSON #11713
Comments
Hey, this doesn't have to be core functionality since you already solved it with a custom formatter :) I also use a custom formatter here: https://github.com/phpstan/phpstan/blob/2.0.x/identifier-extractor/src/ErrorFormatter.php This project used to generate https://phpstan.org/error-identifiers has:
In your case, I'd just recommend you to also only output data to JSON that you need, in order to avoid excessive data file sizes and encode times. |
Hmm, interesting. What about this problem:
I see that you also switch between JSON and Table in the formatter: phpstan/identifier-extractor/src/ErrorFormatter.php Lines 20 to 22 in 62c81ba
This makes it hard for the consumer side to deal with, no? Sure, you can do a |
It makes sense for this JSON formatter to always return 0. I only read the result if the exit code is 0. As for --debug, that's tough. But you don't do that once the code works for you 😊 As for -vvv, all of those things should be printed to stderr. |
Alright, then I'll keep it like this. Thanks for the explanation. And great that my hack was not so hacky after all 😁 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature request
TwigStan is a CLI wrapper around PHPStan. It invokes PHPStan 2 times via the CLI.
The first time to collect data for the PHP files it analyzes. This collected data is then used by TwigStan for the next steps.
The second time to analyze the PHP files for errors. The errors are then processed/transformed and presented to the user.
Currently, there is no easy way to retrieve the collected data via the CLI.
And the
--error-format=json
has some major downsides: the JSON can get corrupted when running with--debug
or-vv
. Especially during development this is annoying.To solve this problem, I created an ErrorFormatter that writes the whole AnalysisResult to a JSON file:
https://github.com/twigstan/twigstan/blob/main/src/PHPStan/AnalysisResultToJson.php
This now solves the above 2 issues.
Since this is a hacky solution, I'd like to discuss how we can improve PHPStan to make this a core functionality :blush
The text was updated successfully, but these errors were encountered: