Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 12, 2024
1 parent fe6ddfc commit 1dbfd30
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ class Fixture
{
public function run()
{
compact('posts', 'units');
$this->setData('posts', 'units');
compact('posts','units');
$this->setData('posts','units');

self::run('posts', 'units');
self::run('posts','units');

self::run('posts', 'units');
self::run('posts',
'units');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class Foo
{
public function doFoo()
{
new self('foo', 'bar');
new self(
'foo',
'bar'
);
}
}
?>
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ public function refactor(Node $node): ?Node
return null;
}

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

return $node;
}
Expand Down
22 changes: 16 additions & 6 deletions tests/Issues/DowngradeHeredoc/Fixture/fixture.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ class Fixture
{
public function getDefinition(): FixerDefinitionInterface
{
return new FixerDefinition('Sorts attributes using the configured sort algorithm.', [
new VersionSpecificCodeSample(<<<'EOL'
return new FixerDefinition(
'Sorts attributes using the configured sort algorithm.',
[
new VersionSpecificCodeSample(
<<<'EOL'
<?php
#[Foo]
Expand All @@ -82,8 +85,11 @@ Corge(a: 'test'),
class Sample2 {}

EOL
, new VersionSpecification(80000)),
new VersionSpecificCodeSample(<<<'EOL'
,
new VersionSpecification(80000)
),
new VersionSpecificCodeSample(
<<<'EOL'
<?php
use A\B\Foo;
Expand All @@ -97,8 +103,12 @@ use A\B as AB;
class Sample1 {}

EOL
, new VersionSpecification(80000), ['sort_algorithm' => self::ORDER_CUSTOM, 'order' => ['A\B\Qux', 'A\B\Bar', 'A\B\Corge']]),
]);
,
new VersionSpecification(80000),
['sort_algorithm' => self::ORDER_CUSTOM, 'order' => ['A\B\Qux', 'A\B\Bar', 'A\B\Corge']]
),
]
);
}
}

Expand Down

0 comments on commit 1dbfd30

Please sign in to comment.