8000 add hidden support to CommandConfigureToAttributeRector · rectorphp/rector-symfony@4c7607f · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c7607f

Browse files
committed
add hidden support to CommandConfigureToAttributeRector
1 parent 1e7aa6b commit 4c7607f

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Rector\Symfony\Tests\Symfony61\Rector\Class_\CommandConfigureToAttributeRector\Fixture;
4+
5+
final class NameAndHidden extends \Symfony\Component\Console\Command\Command
6+
{
7+
public function configure()
8+
{
9+
$this->setName('sunshine');
10+
$this->setAliases(['first', 'second'])
11+
->setHidden(true);
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Symfony\Tests\Symfony61\Rector\Class_\CommandConfigureToAttributeRector\Fixture;
20+
21+
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'sunshine', aliases: ['first', 'second'], hidden: true)]
22+
final class NameAndHidden extends \Symfony\Component\Console\Command\Command
23+
{
24+
public function configure()
25+
{
26+
}
27+
}
28+
29+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Rector\Symfony\Tests\Symfony61\Rector\Class_\CommandConfigureToAttributeRector\Fixture;
4+
5+
final class OtherCallsMiddle extends \Symfony\Component\Console\Command\Command
6+
{
7+
public function configure()
8+
{
9+
$this->setName('sunshine')
10+
->addArgument('argument name')
11+
->setAliases(['first', 'second']);
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Symfony\Tests\Symfony61\Rector\Class_\CommandConfigureToAttributeRector\Fixture;
20+
21+
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'sunshine', aliases: ['first', 'second'])]
22+
final class OtherCallsMiddle extends \Symfony\Component\Console\Command\Command
23+
{
24+
public function configure()
25+
{
26+
$this
27+
->addArgument('argument name');
28+
}
29+
}
30+
31+
?>

rules/Symfony61/Rector/Class_/CommandConfigureToAttributeRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ final class CommandConfigureToAttributeRector extends AbstractRector implements
3939
'setName' => 'name',
4040
'setDescription' => 'description',
4141
'setAliases' => 'aliases',
42+
'setHidden' => 'hidden',
4243
];
4344

4445
public function __construct(

0 commit comments

Comments
 (0)
0