Skip to content

Commit e074aa9

Browse files
committed
[DowngradePhp80/Php73] Handle comma removed on combination DowngradeNamedArgumentRector + DowngradeTrailingCommasInFunctionCallsRector
1 parent 2d0ffeb commit e074aa9

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
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\Tests\Issues\DowngradeNamedTrailing;
6+
7+
use Iterator;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
10+
11+
final class DowngradeNamedTrailingTest 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/configured_rule.php';
27+
}
28+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Rector\Tests\Issues\DowngradeNamedTrailing\Fixture;
4+
5+
class Fixture
6+
{
7+
public function __construct(
8+
protected string $type,
9+
array $data = [],
10+
protected ?string $id = null,
11+
protected ?int $version = null,
12+
protected ?string $key = null,
13+
protected ?string $internalId = null,
14+
protected ?string $externalId = null,
15+
) {
16+
$this->setData($data);
17+
}
18+
}
19+
20+
$contents = new Fixture(
21+
$content->getType(),
22+
id: $content->getId(),
23+
data: ['error' => $e->getMessage()]
24+
);
25+
26+
?>
27+
-----
28+
<?php
29+
30+
namespace Rector\Tests\Issues\DowngradeNamedTrailing\Fixture;
31+
32+
class Fixture
33+
{
34+
public function __construct(
35+
protected string $type,
36+
array $data = [],
37+
protected ?string $id = null,
38+
protected ?int $version = null,
39+
protected ?string $key = null,
40+
protected ?string $internalId = null,
41+
protected ?string $externalId = null,
42+
) {
43+
$this->setData($data);
44+
}
45+
}
46+
47+
$contents = new Fixture(
48+
$content->getType(),
49+
['error' => $e->getMessage()],
50+
$content->getId()
51+
);
52+
53+
?>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Rector\Config\RectorConfig;
4+
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector;
5+
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector;
6+
7+
return RectorConfig::configure()
8+
->withRules([
9+
DowngradeNamedArgumentRector::class,
10+
DowngradeTrailingCommasInFunctionCallsRector::class,
11+
]);

0 commit comments

Comments
 (0)