InvokableCommandInputAttributeRector test fixture#811
Closed
darthf1 wants to merge 1 commit intorectorphp:mainfrom
Closed
InvokableCommandInputAttributeRector test fixture#811darthf1 wants to merge 1 commit intorectorphp:mainfrom
darthf1 wants to merge 1 commit intorectorphp:mainfrom
Conversation
samsonasik
reviewed
Jul 10, 2025
| final class MyCommand | ||
| { | ||
| #[\Override] | ||
| public function __invoke(\Symfony\Component\Console\Style\SymfonyStyle $io): int |
Member
Contributor
Author
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
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
$outputis not used anywhere in__invoke=> remove$outputparam altogether - When
$outputis used fornew SymfonyStyle($input, $output)=> do the change shown here in the pr - But when
$outputis used anywhere else => also keep the$outputparam for__invoke
There was a problem hiding this comment.
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.
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixture for: rectorphp/rector#9254