phpro / grumphp

A PHP code-quality tool
MIT License
4.11k stars 430 forks source link

Add color on phpcsfixer #1025

Open oallain opened 1 year ago

oallain commented 1 year ago
Q A
Branch master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Documented? no
Fixed tickets

Hello, A picture is worth a thousand words, I let you see the result, which is so much more pleasant.

Before before

After after

The inspiration comes from ECS. https://github.com/phpro/grumphp/blob/3ec61c1678c4c370f02b05fef606fd561d923c8e/src/Task/Ecs.php#L71

oallain commented 9 months ago

Hello @veewee

I tried to do what you asked. Tell me if I've forgotten or misunderstood anything.

As for the "--ansi" yes, if not, it doesn't work.

veewee commented 9 months ago

@oallain

I tried to do what you asked. Tell me if I've forgotten or misunderstood anything.>

I probably did not describe it well enough :) Currently the task relies on PhpCsFixerFormatter. This one basically requires the format to be JSON in order to work. If it's not, it falls back to the raw value - which might work in your text case.

However, I don't think we need the custom PhpCsFixerFormatter anymore. That one was introduces to suggest the fix command. Since we introduced a Fixer based on a Process command, I don't think we need that custom formatter anymore.

Instead we could use the raw php-cs-fixer output and print the additionel Process arguments as string in case of failure.

Hope this makes it a bit more clear. Feel free to ask questions if not :)