Skip to content

Commit eec47b7

Browse files
authored
[console] [7.3] Fix missing options in InvokableCommandInputAttributeRector (#839)
* keep option details * add option name * tidy up * fix moving option metadata * Tidy up
1 parent b00a2c7 commit eec47b7

19 files changed

Lines changed: 212 additions & 160 deletions

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"symfony/security-http": "^6.4",
2424
"symfony/validator": "^6.4",
2525
"symfony/web-link": "^6.4",
26+
"symplify/phpstan-extensions": "^12.0",
2627
"symplify/phpstan-rules": "^14.6",
2728
"symplify/vendor-patches": "^11.3",
2829
"tomasvotruba/class-leak": "^2.0",

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ rules:
33

44
parameters:
55
level: 8
6+
errorFormat: symplify
67

78
reportUnmatchedIgnoredErrors: false
89
treatPhpDocTypesAsCertain: false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use Symfony\Component\Console\Output\OutputInterface;
4444
class NameWithHyphen
4545
{
4646
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument-with-hyphen', description: 'Argument description')]
47-
?string $argument_with_hyphen, #[\Symfony\Component\Console\Attribute\Option]
47+
?string $argument_with_hyphen, #[\Symfony\Component\Console\Attribute\Option(name: 'option-with-hyphen')]
4848
$option_with_hyphen): int
4949
{
5050
$argument = $argument_with_hyphen;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use Symfony\Component\Console\Input\InputOption;
4646
final class SomeCommand
4747
{
4848
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
49-
string $argument, #[\Symfony\Component\Console\Attribute\Option]
49+
string $argument, #[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
5050
$option): int
5151
{
5252
$someArgument = $argument;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use Symfony\Component\Console\Input\InputOption;
4747
final class SomeCommandWithMethodChaining
4848
{
4949
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
50-
string $argument, #[\Symfony\Component\Console\Attribute\Option]
50+
string $argument, #[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
5151
$option): int
5252
{
5353
$someArgument = $argument;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ final class SomeCommandWithSetHelp
5252
}
5353

5454
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
55-
string $argument, #[\Symfony\Component\Console\Attribute\Option]
55+
string $argument, #[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
5656
$option): int
5757
{
5858
$someArgument = $argument;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ final class WithMultipleArgumentsOptionsFluent
5656
string $argument1,
5757
#[\Symfony\Component\Console\Attribute\Argument(name: 'argument2', description: 'Argument2 description')]
5858
string $argument2,
59-
#[\Symfony\Component\Console\Attribute\Option]
59+
#[\Symfony\Component\Console\Attribute\Option(name: 'option1', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option1 description')]
6060
$option1,
61-
#[\Symfony\Component\Console\Attribute\Option]
61+
#[\Symfony\Component\Console\Attribute\Option(name: 'option2', shortcut: 'p', mode: InputOption::VALUE_NONE, description: 'Option2 description')]
6262
$option2
6363
): int
6464
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ final class WithMultipleArgumentsOptionsNotFluent
6161
string $argument1,
6262
#[\Symfony\Component\Console\Attribute\Argument(name: 'argument2', description: 'Argument2 description')]
6363
string $argument2,
64-
#[\Symfony\Component\Console\Attribute\Option]
64+
#[\Symfony\Component\Console\Attribute\Option(name: 'option1', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option1 description')]
6565
$option1,
66-
#[\Symfony\Component\Console\Attribute\Option]
66+
#[\Symfony\Component\Console\Attribute\Option(name: 'option2', shortcut: 'p', mode: InputOption::VALUE_NONE, description: 'Option2 description')]
6767
$option2
6868
): int
6969
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use Symfony\Component\Console\Input\InputOption;
4646
final class WithOptionalArgument
4747
{
4848
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
49-
?string $argument, #[\Symfony\Component\Console\Attribute\Option]
49+
?string $argument, #[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
5050
$option): int
5151
{
5252
$someArgument = $argument;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class WithOverride
5050
public function __invoke(
5151
#[\Symfony\Component\Console\Attribute\Argument(name: 'argument', description: 'Argument description')]
5252
string $argument,
53-
#[\Symfony\Component\Console\Attribute\Option]
53+
#[\Symfony\Component\Console\Attribute\Option(name: 'option', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option description')]
5454
$option
5555
): int
5656
{

0 commit comments

Comments
 (0)