Skip to content

Commit d39d176

Browse files
authored
[SYMFONY 7.4] replace function call (#828)
1 parent 8f7905f commit d39d176

File tree

6 files changed

+92
-0
lines changed

6 files changed

+92
-0
lines changed

config/sets/symfony/symfony7/symfony74.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
return static function (RectorConfig $rectorConfig): void {
1010
$rectorConfig->import(__DIR__ . '/symfony74/symfony74-console.php');
1111
$rectorConfig->import(__DIR__ . '/symfony74/symfony74-framework-bundle.php');
12+
$rectorConfig->import(__DIR__ . '/symfony74/symfony74-routing.php');
1213
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
7+
use Rector\Renaming\ValueObject\MethodCallRename;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
11+
// @see https://github.com/symfony/symfony/pull/61358
12+
new MethodCallRename('Symfony\Component\Routing\Attribute\Route', 'setEnv', 'setEnvs'),
13+
]);
14+
};

src/Set/SetProvider/Symfony7SetProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ public function provide(): array
129129
'7.4',
130130
__DIR__ . '/../../../config/sets/symfony/symfony7/symfony74/symfony74-framework-bundle.php'
131131
),
132+
new ComposerTriggeredSet(
133+
SetGroup::SYMFONY,
134+
'symfony/routing',
135+
'7.4',
136+
__DIR__ . '/../../../config/sets/symfony/symfony7/symfony74/symfony74-routing.php'
137+
),
132138
];
133139
}
134140
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Rector\Symfony\Tests\Set\Symfony74\Fixture;
4+
5+
use Symfony\Component\Routing\Attribute\Route;
6+
7+
class RouterSetEnvToSetEnvs
8+
{
9+
public function someAction()
10+
{
11+
$route = new Route('/path');
12+
$route->setEnv('prod');
13+
}
14+
}
15+
16+
?>
17+
-----
18+
<?php
19+
20+
namespace Rector\Symfony\Tests\Set\Symfony74\Fixture;
21+
22+
use Symfony\Component\Routing\Attribute\Route;
23+
24+
class RouterSetEnvToSetEnvs
25+
{
26+
public function someAction()
27+
{
28+
$route = new Route('/path');
29+
$route->setEnvs('prod');
30+
}
31+
}
32+
33+
?>
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\Symfony74;
6+
7+
use Iterator;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
10+
11+
final class Symfony74Test 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/symfony74.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_74]);
10+
};

0 commit comments

Comments
 (0)