Skip to content
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

Add color on phpcsfixer #1025

Open
wants to merge 1 commit into
base: v2.x
Choose a base branch
from
Open

Conversation

oallain
Copy link
Contributor

@oallain oallain commented Jul 9, 2022

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.

$arguments->addOptionalArgument('--ansi', true);

@@ -71,11 +71,12 @@ public function run(ContextInterface $context): TaskResultInterface
$this->formatter->resetCounter();

$arguments = $this->processBuilder->createArgumentsForCommand('php-cs-fixer');
$arguments->add('--format=json');
$arguments->add('--format=txt');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this task is using a dedicated formatter (GrumPHP\Formatter\PhpCsFixerFormatter), that this change will break

Copy link
Contributor

@veewee veewee Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this will bypass the custom formatter.
However, the formatter is quite old and was used to propose a way of fixing the code.
Now that we have our fixer configuration - which used the process to build de fixer process - it seems safe to nuke that custom formatter. It doesn't really provide any benefits anymore + it seems better to rely on the official php-cs-fixer formatters.

@oallain : Can you:

  • remove the custom formatter and it's implementation
  • provide a configurable format string option with a default of txt
  • add documentation for these options?

Do we need to specify --ansi?
Normally the system is smart enough to detect ansi or not.

@veewee veewee changed the base branch from master to v2.x June 18, 2023 13:29
@oallain
Copy link
Contributor Author

oallain commented Sep 23, 2023

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
Copy link
Contributor

veewee commented Sep 29, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants