Skip to content

Commit 1dbfd30

Browse files
committed
fix
1 parent fe6ddfc commit 1dbfd30

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

rules-tests/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/Fixture/fixture.php.inc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ class Fixture
2626
{
2727
public function run()
2828
{
29-
compact('posts', 'units');
30-
$this->setData('posts', 'units');
29+
compact('posts','units');
30+
$this->setData('posts','units');
3131

32-
self::run('posts', 'units');
32+
self::run('posts','units');
3333

34-
self::run('posts', 'units');
34+
self::run('posts',
35+
'units');
3536
}
3637
}
3738

rules-tests/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/Fixture/new.php.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class Foo
2222
{
2323
public function doFoo()
2424
{
25-
new self('foo', 'bar');
25+
new self(
26+
'foo',
27+
'bar'
28+
);
2629
}
2730
}
2831
?>

rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ public function refactor(Node $node): ?Node
9090
return null;
9191
}
9292

93-
// remove comma
94-
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
93+
$tokens = $this->file->getOldTokens();
94+
if (isset($tokens[$args[$lastArgKey]->getEndTokenPos() + 1]) && $tokens[$args[$lastArgKey]->getEndTokenPos() + 1]->text === ',') {
95+
$tokens[$args[$lastArgKey]->getEndTokenPos() + 1]->text = '';
96+
}
9597

9698
return $node;
9799
}

tests/Issues/DowngradeHeredoc/Fixture/fixture.php.inc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ class Fixture
6363
{
6464
public function getDefinition(): FixerDefinitionInterface
6565
{
66-
return new FixerDefinition('Sorts attributes using the configured sort algorithm.', [
67-
new VersionSpecificCodeSample(<<<'EOL'
66+
return new FixerDefinition(
67+
'Sorts attributes using the configured sort algorithm.',
68+
[
69+
new VersionSpecificCodeSample(
70+
<<<'EOL'
6871
<?php
6972
7073
#[Foo]
@@ -82,8 +85,11 @@ Corge(a: 'test'),
8285
class Sample2 {}
8386

8487
EOL
85-
, new VersionSpecification(80000)),
86-
new VersionSpecificCodeSample(<<<'EOL'
88+
,
89+
new VersionSpecification(80000)
90+
),
91+
new VersionSpecificCodeSample(
92+
<<<'EOL'
8793
<?php
8894
8995
use A\B\Foo;
@@ -97,8 +103,12 @@ use A\B as AB;
97103
class Sample1 {}
98104

99105
EOL
100-
, new VersionSpecification(80000), ['sort_algorithm' => self::ORDER_CUSTOM, 'order' => ['A\B\Qux', 'A\B\Bar', 'A\B\Corge']]),
101-
]);
106+
,
107+
new VersionSpecification(80000),
108+
['sort_algorithm' => self::ORDER_CUSTOM, 'order' => ['A\B\Qux', 'A\B\Bar', 'A\B\Corge']]
109+
),
110+
]
111+
);
102112
}
103113
}
104114

0 commit comments

Comments
 (0)