Skip to content

Commit f4c3792

Browse files
committed
fix printer by using new ClassMethod
1 parent 80598eb commit f4c3792

File tree

12 files changed

+114
-138
lines changed

12 files changed

+114
-138
lines changed

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/DefaultValue/match_scalar_type.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class MatchScalarType
4848
public function __invoke(
4949
#[\Symfony\Component\Console\Attribute\Argument(name: 'first')]
5050
?int $first = 100,
51-
#[\Symfony\Component\Console\Attribute\Argument(name: 'second')]
52-
float $second = 200.5,
5351
#[\Symfony\Component\Console\Attribute\Option(name: 'third')]
5452
int $third = 200,
53+
#[\Symfony\Component\Console\Attribute\Argument(name: 'second')]
54+
float $second = 200.5,
5555
#[\Symfony\Component\Console\Attribute\Option(name: 'fourth')]
5656
float $fourth = 400.5
5757
): int

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/DefaultValue/option_with_array_type.php.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ use Symfony\Component\Console\Output\OutputInterface;
4242
)]
4343
class OptionWithOptionalValue
4444
{
45-
public function __invoke(#[\Symfony\Component\Console\Attribute\Option(name: 'some-array', mode: InputOption::VALUE_IS_ARRAY)]
46-
array $someArray = ['third value'], #[\Symfony\Component\Console\Attribute\Option(name: 'no-default-array', mode: InputOption::VALUE_IS_ARRAY)]
47-
array $noDefaultArray): int
45+
public function __invoke(
46+
#[\Symfony\Component\Console\Attribute\Option(name: 'no-default-array', mode: InputOption::VALUE_IS_ARRAY)]
47+
array $noDefaultArray,
48+
#[\Symfony\Component\Console\Attribute\Option(name: 'some-array', mode: InputOption::VALUE_IS_ARRAY)]
49+
array $someArray = ['third value']
50+
): int
4851
{
4952
}
5053
}

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/command_with_io.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
3434
#[AsCommand('app:my-command')]
3535
final class MyCommand
3636
{
37-
public function __invoke(\Symfony\Component\Console\Style\SymfonyStyle $io): int
37+
public function __invoke(OutputInterface $output, \Symfony\Component\Console\Style\SymfonyStyle $io): int
3838
{
3939
$io->info('Great success!');
4040
return 1;

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/name_from_constant.php.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ use Symfony\Component\Console\Output\OutputInterface;
5151
class NameFromConstant
5252
{
5353
private const string ARGUMENT_NAME = 'name';
54-
5554
public function __invoke(
5655
#[\Symfony\Component\Console\Attribute\Argument(name: self::ARGUMENT_NAME, description: 'The name of the person to greet.')]
5756
?string $name,

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/name_with_hyphen.php.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ use Symfony\Component\Console\Output\OutputInterface;
4343
)]
4444
class NameWithHyphen
4545
{
46-
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument-with-hyphen', description: 'Argument description')]
47-
?string $argumentWithHyphen, #[\Symfony\Component\Console\Attribute\Option(name: 'option-with-hyphen')]
48-
$optionWithHyphen): int
46+
public function __invoke(
47+
#[\Symfony\Component\Console\Attribute\Argument(name: 'argument-with-hyphen', description: 'Argument description')]
48+
?string $argumentWithHyphen,
49+
#[\Symfony\Component\Console\Attribute\Option(name: 'option-with-hyphen')]
50+
$optionWithHyphen
51+
): int
4952
{
5053
$argument = $argument_with_hyphen;
5154
$option = $option_with_hyphen;

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/option_name_constant.php.inc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,16 @@ final class OptionNameConstant
5353
private const ARGUMENT_NAME = 'some-argument';
5454

5555
private const OPTION_NAME = 'some-option';
56-
57-
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: self::ARGUMENT_NAME)]
58-
?string $someArgument, #[\Symfony\Component\Console\Attribute\Option(name: self::OPTION_NAME)]
59-
$someOption): int
56+
public function __invoke(
57+
#[\Symfony\Component\Console\Attribute\Argument(name: self::ARGUMENT_NAME)]
58+
?string $someArgument,
59+
#[\Symfony\Component\Console\Attribute\Option(name: self::OPTION_NAME)]
60+
$someOption
61+
): int
6062
{
6163
$someArgument = $some_argument;
62-
6364
$someOption = $some_option;
64-
6565
// ...
66-
6766
return 1;
6867
}
6968
}

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/some_command.php.inc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@ use Symfony\Component\Console\Input\InputOption;
4545
#[AsCommand(name: 'some_name')]
4646
final class SomeCommand
4747
{
48-
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
49-
string $argument, #[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
50-
bool $option = false): int
48+
public function __invoke(
49+
#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
50+
string $argument,
51+
#[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
52+
bool $option = false
53+
): int
5154
{
5255
$someArgument = $argument;
5356
$someOption = $option;
54-
5557
// ...
56-
5758
return 1;
5859
}
5960
}

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/some_command_with_method_chaining.php.inc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@ use Symfony\Component\Console\Input\InputOption;
4646
#[AsCommand(name: 'some_name')]
4747
final class SomeCommandWithMethodChaining
4848
{
49-
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
50-
string $argument, #[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
51-
bool $option = false): int
49+
public function __invoke(
50+
#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
51+
string $argument,
52+
#[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
53+
bool $option = false
54+
): int
5255
{
5356
$someArgument = $argument;
5457
$someOption = $option;
55-
5658
// ...
57-
5859
return 1;
5960
}
6061
}

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/some_command_with_set_help.php.inc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ final class SomeCommandWithSetHelp
5151
$this->setHelp('argument');
5252
}
5353

54-
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
55-
string $argument, #[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
56-
bool $option = false): int
54+
public function __invoke(
55+
#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
56+
string $argument,
57+
#[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
58+
bool $option = false
59+
): int
5760
{
5861
$someArgument = $argument;
5962
$someOption = $option;
60-
6163
// ...
62-
6364
return 1;
6465
}
6566
}

rules-tests/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector/Fixture/with_default_and_without_default_value.php.inc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,21 @@ use Symfony\Component\Console\Input\InputOption;
4646
#[AsCommand(name: 'some_name')]
4747
final class WithDefaultAndWithoutDefaultValue
4848
{
49-
public function __invoke(#[\Symfony\Component\Console\Attribute\Option(name: 'another', shortcut: 'a', mode: InputOption::VALUE_REQUIRED, description: 'No default value')]
50-
$another, OutputInterface $output, #[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
51-
bool $option = false): int
49+
public function __invoke(
50+
#[\Symfony\Component\Console\Attribute\Option(name: 'another', shortcut: 'a', mode: InputOption::VALUE_REQUIRED, description: 'No default value')]
51+
$another,
52+
OutputInterface $output,
53+
#[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
54+
bool $option = false
55+
): int
5256
{
5357
$someOption = $option;
5458
$another = $another;
5559
$output->writeln('Using output too');
56-
5760
// ...
58-
5961
return 1;
6062
}
6163
}
6264

6365
?>
66+

0 commit comments

Comments
 (0)