Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rules/DowngradePhp80/NodeAnalyzer/NamedToUnnamedArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function fillFromNamedArgs(
$currentArg->value,
$currentArg->byRef,
$currentArg->unpack,
$currentArg->getAttributes(),
[],
null
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function resolveFromReflection(

foreach ($currentArgs as $key => $arg) {
if (! $arg->name instanceof Identifier) {
$unnamedArgs[$key] = new Arg($arg->value, $arg->byRef, $arg->unpack, $arg->getAttributes(), null);
$unnamedArgs[$key] = new Arg($arg->value, $arg->byRef, $arg->unpack, [], null);

continue;
}
Expand Down
28 changes: 28 additions & 0 deletions tests/Issues/DowngradeNamedTrailing/DowngradeNamedTrailingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Issues\DowngradeNamedTrailing;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class DowngradeNamedTrailingTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}
}
53 changes: 53 additions & 0 deletions tests/Issues/DowngradeNamedTrailing/Fixture/fixture.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Rector\Tests\Issues\DowngradeNamedTrailing\Fixture;

class Fixture
{
public function __construct(
protected string $type,
array $data = [],
protected ?string $id = null,
protected ?int $version = null,
protected ?string $key = null,
protected ?string $internalId = null,
protected ?string $externalId = null,
) {
$this->setData($data);
}
}

$contents = new Fixture(
$content->getType(),
id: $content->getId(),
data: ['error' => $e->getMessage()]
);

?>
-----
<?php

namespace Rector\Tests\Issues\DowngradeNamedTrailing\Fixture;

class Fixture
{
public function __construct(
protected string $type,
array $data = [],
protected ?string $id = null,
protected ?int $version = null,
protected ?string $key = null,
protected ?string $internalId = null,
protected ?string $externalId = null,
) {
$this->setData($data);
}
}

$contents = new Fixture(
$content->getType(),
['error' => $e->getMessage()],
$content->getId()
);

?>
10 changes: 10 additions & 0 deletions tests/Issues/DowngradeNamedTrailing/config/configured_rule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector;
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector;

return RectorConfig::configure()
->withRules([DowngradeNamedArgumentRector::class, DowngradeTrailingCommasInFunctionCallsRector::class]);
Loading