grumphp icon indicating copy to clipboard operation
grumphp copied to clipboard

Add color on phpcsfixer

Open oallain opened this issue 3 years ago • 3 comments

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 avatar Jul 09 '22 20:07 oallain

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.

oallain avatar Sep 23 '23 21:09 oallain

@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 :)

veewee avatar Sep 29 '23 08:09 veewee