Skip to content

Commit 5d63ac2

Browse files
committed
[Symfony 7.3] add constant and test for 7.3 and test help to attribute
1 parent 9a4e2c8 commit 5d63ac2

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

src/Set/SymfonySetList.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ final class SymfonySetList
160160
*/
161161
final public const SYMFONY_72 = __DIR__ . '/../../config/sets/symfony/symfony72.php';
162162

163+
/**
164+
* @var string
165+
*/
166+
final public const SYMFONY_73 = __DIR__ . '/../../config/sets/symfony/symfony73.php';
167+
163168
/**
164169
* @var string
165170
*/
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace Rector\Symfony\Tests\Set\Symfony73\Fixture;
4+
5+
use Symfony\Component\Console\Attribute\AsCommand;
6+
use Symfony\Component\Console\Command\Command;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Output\OutputInterface;
9+
use Symfony\Component\Console\Input\InputArgument;
10+
use Symfony\Component\Console\Input\InputOption;
11+
12+
#[AsCommand(name: 'some_name')]
13+
final class SomeCommand extends Command
14+
{
15+
public function configure()
16+
{
17+
$this->setHelp('argument');
18+
$this->addArgument('argument', InputArgument::REQUIRED, 'Argument description');
19+
$this->addOption('option', 'o', InputOption::VALUE_NONE, 'Option description');
20+
}
21+
22+
public function execute(InputInterface $input, OutputInterface $output): int
23+
{
24+
$someArgument = $input->getArgument('argument');
25+
$someOption = $input->getOption('option');
26+
27+
// ...
28+
29+
return 1;
30+
}
31+
}
32+
33+
?>
34+
-----
35+
<?php
36+
37+
namespace Rector\Symfony\Tests\Set\Symfony73\Fixture;
38+
39+
use Symfony\Component\Console\Attribute\AsCommand;
40+
use Symfony\Component\Console\Command\Command;
41+
use Symfony\Component\Console\Input\InputInterface;
42+
use Symfony\Component\Console\Output\OutputInterface;
43+
use Symfony\Component\Console\Input\InputArgument;
44+
use Symfony\Component\Console\Input\InputOption;
45+
46+
#[AsCommand(name: 'some_name', help: 'argument')]
47+
final class SomeCommand
48+
{
49+
public function __invoke(#[\Symfony\Component\Console\Attribute\Command\Argument]
50+
string $argument, #[\Symfony\Component\Console\Attribute\Command\Option]
51+
$option): int
52+
{
53+
$someArgument = $argument;
54+
$someOption = $option;
55+
56+
// ...
57+
58+
return 1;
59+
}
60+
}
61+
62+
?>

tests/Set/Symfony73/Symfony73Test.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Symfony\Tests\Set\Symfony73;
6+
7+
use Iterator;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
10+
11+
final class Symfony73Test extends AbstractRectorTestCase
12+
{
13+
#[DataProvider('provideData')]
14+
public function test(string $filePath): void
15+
{
16+
$this->doTestFile($filePath);
17+
}
18+
19+
public static function provideData(): Iterator
20+
{
21+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
22+
}
23+
24+
public function provideConfigFilePath(): string
25+
{
26+
return __DIR__ . '/config/symfony73.php';
27+
}
28+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Symfony\Set\SymfonySetList;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
$rectorConfig->sets([SymfonySetList::SYMFONY_73]);
10+
};

0 commit comments

Comments
 (0)