-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
[Feat] Add formatting support #201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
I left some comments, but it's really good.
Formatters are simple to understand and this allow us to possibly add more format in the future (xml, html... 😄)
About the json structure, there is some plugin/library able to parse it and generate some report ?
@Jibbarth Thanks for the review! So there is nothing that can parse this json, this is just a custom format that we specified ourself. However it opens up for the possiblity of tools doing that in the future. When we settle on a design, we should add a json structure file also. Yeah, tried to make the formatter as simple as possible. We could actually add a xml formatter by wrapping the json formatter and converting the json to xml 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's ok.
For docs, do you want to continue on this PR or on another ?
@Jibbarth let's do the docs in another PR. (I am totally fine with you doing it also 😏) I won't be able to do any work before the end of the week as I am on vacation. ⛱️ |
@olivernybroe Make sure you enjoy your vacations! |
@nunomaduro As you self-requested a review, I let you check this before going further, because it's a big change. Ok with that ? |
Just finished the docs and the schema file. This PR should be ready now :) |
Didn't had time to check this yet, do you mind of waiting? I am so sorry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats @olivernybroe on this pull request, there is tons of improvement, you really nailed it.
Let's make sure we address my feedback before merging.
} | ||
|
||
/** | ||
* @param mixed $original |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have no idea about what is coming for original
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I can add the Sniff error class and keep mixed?
As right now the only data which is added in here is actually the sniff error, but for example with the phpstan error class a new type is added to this also.
We could also remove the original all together as we actually don't use it anywhere yet?
@Jibbarth Let's wait with merging this until @nunomaduro approves it. 👍 |
Thanks buddy, impressive work on this. Great pull request and feature. |
This PR adds support for formatting the output is different formats.
You can now format to following outputs
To use it simply add
--format=json
, or--format=console
(console is default and fallback).This PR also adds support for piping the result to a file (useful when formatting to json).
This means you can do
phpinsights analyse--format=json > test.json
and you will get the following result:And the following data in the json file https://gist.github.com/olivernybroe/b68d0c66370a91486a138dcf8de102cd
One gotcha is when piping the result and using the console format without no interaction on, you have to press enter even though you cannot see the result as you are piping it to somewhere else. (don't know why you would pipe the result when using console format)
Another gotcha is that pipes does not support ANSI, so to get colored output while piping, you have to add the
--ansi
flag.Adding a little todo with stuff I'll def forget if I dont add it here.