Skip to content

InvokableCommandInputAttributeRector test fixture #811

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

darthf1
Copy link

@darthf1 darthf1 commented Jul 10, 2025

fixture for: rectorphp/rector#9254

final class MyCommand
{
#[\Override]
public function __invoke(\Symfony\Component\Console\Style\SymfonyStyle $io): int
Copy link
Member

Choose a reason for hiding this comment

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

I think it should not be replaced, skip the change should be the way, right? /cc @darthf1 @thePanz @gharlan could you verify? Thank you.

Copy link
Author

@darthf1 darthf1 Jul 10, 2025

Choose a reason for hiding this comment

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

The blog post has this (almost) exact example, and there $input and $output is changed into $io as well.

https://symfony.com/blog/new-in-symfony-7-3-invokable-commands-and-input-attributes

Copy link
Contributor

Choose a reason for hiding this comment

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

I made this change in most of my commands after using the InvokableCommandInputAttributeRector.

But I also had some commands where I used the $output as argument for other functions. So there I still need the $output param.

Best would be:

  • When $output is not used anywhere in __invoke => remove $output param altogether
  • When $output is used for new SymfonyStyle($input, $output) => do the change shown here in the pr
  • But when $output is used anywhere else => also keep the $output param for __invoke

Copy link

Choose a reason for hiding this comment

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

as this is a bugfix, I would keep a KISS solution: @samsonasik 's suggestion to not rewrite the parameters in the constructor looks reasonable as a first step.

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.

4 participants