Skip to content

Add Mago as task#1216

Open
johnatas-x wants to merge 2 commits intophpro:v2.xfrom
johnatas-x:mago-task
Open

Add Mago as task#1216
johnatas-x wants to merge 2 commits intophpro:v2.xfrom
johnatas-x:mago-task

Conversation

@johnatas-x
Copy link
Copy Markdown

Q A
Branch mago-task
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Documented? yes
Fixed tickets #1193

This PR adds a Mago task

Mago is a recent tool that includes a formatter (like phpcs), a linter (like phpmd), and a static analyzer (like phpstan).
It is known for its performance and is starting to be increasingly adopted (for example, in Drupal).
Its integration into GrumPHP seems valuable.

New Task Checklist:

  • Are the dependencies added to the composer.json suggestions?
  • Is the doc/tasks.md file updated?
  • Are the task parameters documented?
  • Is the task registered in the tasks.yml file?
  • Does the task contains phpunit tests?
  • Is the configuration having logical allowed types?
  • Does the task run in the correct context?
  • Is the run() method readable?
  • Is the run() method using the configuration correctly?
  • Are all CI services returning green?

@johnatas-x johnatas-x mentioned this pull request Apr 30, 2026
Copy link
Copy Markdown
Contributor

@veewee veewee left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.
I think this task in current state is not in line with other tasks. I've added some remarks inline in the code. Feel free to stat a discussion.

Comment thread src/Task/Mago.php
$resolver = new OptionsResolver();
$resolver->setDefaults([
'formatter' => true,
'formatter_options' => ['--staged'],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

staged should only be a default during pre-commit I suppose?

Comment thread src/Task/Mago.php
]);

$resolver->addAllowedTypes('formatter', ['bool']);
$resolver->addAllowedTypes('formatter_options', ['array']);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In other tasks, we provide configuration keys that map the options of the CLI.
Doing it like this introduces a new way of configuring tasks, which I'dd like to avoid at this point.

Comment thread src/Task/Mago.php
{
$config = $this->getConfig()->getOptions();

if ($config['formatter'] === false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was thinking: wouldn't it make more sense to introduce a task per type of command?
Something like following tasks:

  • mago_fmt
  • mago_lint
  • mago_analyze
  • mago_guard

Every task will have it's own set of configurable options.

@johnatas-x
Copy link
Copy Markdown
Author

Hey @veewee,

Thanks for taking the time to review the PR and share your feedback.
Your comments align with the questions I raised in the related issue.

To be fully transparent, after opening the PR I had already started reworking it to introduce 4 commands. I’ll update the PR this week with those changes; it should end up closer to how the SecurityChecker tasks are structured, which should resolve the three threads.

If you have any additional feedback, feel free to share it so I can address everything at once.

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.

2 participants