-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp73] Handle heredoc new line stripped on multi rules (#257)
* [DowngradePhp73] Handle heredoc new line stripped on multi rules * fix * [ci-review] Rector Rectify * add fixture multi space * fix --------- Co-authored-by: GitHub Action <[email protected]>
- Loading branch information
1 parent
0ed4563
commit 3aebc81
Showing
7 changed files
with
202 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector/Fixture/multi_space.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector\Fixture; | ||
|
||
// @see https://3v4l.org/POahP#v7.2.17 | ||
class MultiSpace | ||
{ | ||
public function run() | ||
{ | ||
self::run('posts','units' , ); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector\Fixture; | ||
|
||
// @see https://3v4l.org/POahP#v7.2.17 | ||
class MultiSpace | ||
{ | ||
public function run() | ||
{ | ||
self::run('posts','units' ); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,10 @@ class Foo | |
{ | ||
public function doFoo() | ||
{ | ||
new self('foo', 'bar'); | ||
new self( | ||
'foo', | ||
'bar' | ||
); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Issues\DowngradeHeredoc; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class DowngradeHeredocTest 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'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\DowngradeNullJson\DowngradeHeredoc; | ||
|
||
class Fixture | ||
{ | ||
public function getDefinition(): FixerDefinitionInterface | ||
{ | ||
return new FixerDefinition( | ||
'Sorts attributes using the configured sort algorithm.', | ||
[ | ||
new VersionSpecificCodeSample( | ||
<<<'EOL' | ||
<?php | ||
#[Foo] | ||
#[Bar(3)] | ||
#[Qux(new Bar(5))] | ||
#[Corge(a: 'test')] | ||
class Sample1 {} | ||
#[ | ||
Foo, | ||
Bar(3), | ||
Qux(new Bar(5)), | ||
Corge(a: 'test'), | ||
] | ||
class Sample2 {} | ||
|
||
EOL, | ||
new VersionSpecification(8_00_00), | ||
), | ||
new VersionSpecificCodeSample( | ||
<<<'EOL' | ||
<?php | ||
use A\B\Foo; | ||
use A\B\Bar as BarAlias; | ||
use A\B as AB; | ||
#[Foo] | ||
#[BarAlias(3)] | ||
#[AB\Qux(new Bar(5))] | ||
#[\A\B\Corge(a: 'test')] | ||
class Sample1 {} | ||
|
||
EOL, | ||
new VersionSpecification(8_00_00), | ||
['sort_algorithm' => self::ORDER_CUSTOM, 'order' => ['A\B\Qux', 'A\B\Bar', 'A\B\Corge']], | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\DowngradeNullJson\DowngradeHeredoc; | ||
|
||
class Fixture | ||
{ | ||
public function getDefinition(): FixerDefinitionInterface | ||
{ | ||
return new FixerDefinition( | ||
'Sorts attributes using the configured sort algorithm.', | ||
[ | ||
new VersionSpecificCodeSample( | ||
<<<'EOL' | ||
<?php | ||
#[Foo] | ||
#[Bar(3)] | ||
#[Qux(new Bar(5))] | ||
#[Corge(a: 'test')] | ||
class Sample1 {} | ||
#[ | ||
Foo, | ||
Bar(3), | ||
Qux(new Bar(5)), | ||
Corge(a: 'test'), | ||
] | ||
class Sample2 {} | ||
|
||
EOL | ||
, | ||
new VersionSpecification(80000) | ||
), | ||
new VersionSpecificCodeSample( | ||
<<<'EOL' | ||
<?php | ||
use A\B\Foo; | ||
use A\B\Bar as BarAlias; | ||
use A\B as AB; | ||
#[Foo] | ||
#[BarAlias(3)] | ||
#[AB\Qux(new Bar(5))] | ||
#[\A\B\Corge(a: 'test')] | ||
class Sample1 {} | ||
|
||
EOL | ||
, | ||
new VersionSpecification(80000), | ||
['sort_algorithm' => self::ORDER_CUSTOM, 'order' => ['A\B\Qux', 'A\B\Bar', 'A\B\Corge']] | ||
), | ||
] | ||
); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\Set\ValueObject\DowngradeLevelSetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72]); | ||
}; |