Skip to content

Commit e58fca3

Browse files
committed
[Symfony 7.3] Make __invoke() public in InvokableCommandInputAttributeRector
1 parent 13a3990 commit e58fca3

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class NameFromConstant
5252
{
5353
private const string ARGUMENT_NAME = 'name';
5454

55-
protected function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: self::ARGUMENT_NAME, description: 'The name of the person to greet.')]
55+
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: self::ARGUMENT_NAME, description: 'The name of the person to greet.')]
5656
?string $name, OutputInterface $output): int
5757
{
5858
$name = $name;
@@ -61,4 +61,4 @@ class NameFromConstant
6161
}
6262
}
6363

64-
?>
64+
?>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ use Symfony\Component\Console\Input\InputOption;
1212
#[AsCommand(name: 'some_name')]
1313
final class SomeCommandWithSetHelp extends Command
1414
{
15-
public function configure()
15+
protected function configure()
1616
{
1717
$this->setHelp('argument');
1818
$this->addArgument('argument', InputArgument::REQUIRED, 'Argument description');
1919
$this->addOption('option', 'o', InputOption::VALUE_NONE, 'Option description');
2020
}
2121

22-
public function execute(InputInterface $input, OutputInterface $output): int
22+
protected function execute(InputInterface $input, OutputInterface $output): int
2323
{
2424
$someArgument = $input->getArgument('argument');
2525
$someOption = $input->getOption('option');
@@ -46,7 +46,7 @@ use Symfony\Component\Console\Input\InputOption;
4646
#[AsCommand(name: 'some_name')]
4747
final class SomeCommandWithSetHelp
4848
{
49-
public function configure()
49+
protected function configure()
5050
{
5151
$this->setHelp('argument');
5252
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use Symfony\Component\Console\Input\InputOption;
1212
#[AsCommand(name: 'some_name')]
1313
final class WithOptionalArgument extends Command
1414
{
15-
public function configure()
15+
protected function configure()
1616
{
1717
$this->addArgument('argument', InputArgument::OPTIONAL, 'Argument description');
1818
$this->addOption('option', 'o', InputOption::VALUE_NONE, 'Option description');
1919
}
2020

21-
public function execute(InputInterface $input, OutputInterface $output): int
21+
protected function execute(InputInterface $input, OutputInterface $output): int
2222
{
2323
$someArgument = $input->getArgument('argument');
2424
$someOption = $input->getOption('option');

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ use Symfony\Component\Console\Input\InputOption;
1313
final class WithOverride extends Command
1414
{
1515
#[\Override]
16-
public function configure()
16+
protected function configure()
1717
{
1818
$this->addArgument('argument', InputArgument::REQUIRED, 'Argument description');
1919
$this->addOption('option', 'o', InputOption::VALUE_NONE, 'Option description');
2020
}
2121

2222
#[\Override]
23-
public function execute(InputInterface $input, OutputInterface $output): int
23+
protected function execute(InputInterface $input, OutputInterface $output): int
2424
{
2525
$someArgument = $input->getArgument('argument');
2626
$someOption = $input->getOption('option');

rules/Symfony73/Rector/Class_/InvokableCommandInputAttributeRector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\Symfony\Symfony73\Rector\Class_;
66

7+
use PhpParser\Modifiers;
78
use PhpParser\Node;
89
use PhpParser\Node\Attribute;
910
use PhpParser\Node\Expr\ClassConstFetch;
@@ -147,6 +148,7 @@ public function refactor(Node $node): ?Class_
147148
}
148149

149150
$executeClassMethod->name = new Identifier('__invoke');
151+
$executeClassMethod->flags = Modifiers::PUBLIC;
150152

151153
// 3. create arguments and options parameters
152154
// @todo

0 commit comments

Comments
 (0)