-
Notifications
You must be signed in to change notification settings - Fork 24
Downgrade pipe operator #337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c0b138c
downgrade pipe
arshidkv12 813b467
Downgrade php85 pipe
arshidkv12 f11cf57
Downgrade php85 pipe
arshidkv12 4e5375a
Downgrade php85 pipe
arshidkv12 89cdbb6
Downgrade php85 pipe
arshidkv12 67ff41e
Downgrade php85 pipe
arshidkv12 ab0cbb7
CI - PHP85
arshidkv12 66bfdb4
Downgrade php85 pipe
arshidkv12 f9594a3
Downgrade php85 pipe
arshidkv12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
30 changes: 30 additions & 0 deletions
30
...r/StmtsAwareInterface/DowngradePipeOperatorRectorTest/DowngradePipeOperatorRectorTest.php
This file contains hidden or 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,30 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector; | ||
|
|
||
| use Iterator; | ||
| use PHPUnit\Framework\Attributes\DataProvider; | ||
| use PHPUnit\Framework\Attributes\RequiresPhp; | ||
| use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
|
||
| final class DowngradePipeOperatorRectorTest extends AbstractRectorTestCase | ||
| { | ||
| #[DataProvider('provideData')] | ||
| #[RequiresPhp('>= 8.5')] | ||
| 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'; | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
...or/StmtsAwareInterface/DowngradePipeOperatorRectorTest/Fixture/complex_pipe_chain.php.inc
This file contains hidden or 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\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $data = " Hello, World! "; | ||
| $processed = $data | ||
| |> trim(...) | ||
| |> strtoupper(...) | ||
| |> (fn($str) => str_replace('WORLD', 'PHP', $str)) | ||
| |> addslashes(...); | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $data = " Hello, World! "; | ||
| $result1 = trim($data); | ||
| $result2 = strtoupper($result1); | ||
| $result3 = (fn($str) => str_replace('WORLD', 'PHP', $str))($result2); | ||
| $processed = addslashes($result3); | ||
|
|
||
| ?> |
26 changes: 26 additions & 0 deletions
26
...Rector/StmtsAwareInterface/DowngradePipeOperatorRectorTest/Fixture/multiple_pipes.php.inc
This file contains hidden or 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,26 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $value = "hello world"; | ||
| $result = $value | ||
| |> function3(...) | ||
| |> function2(...) | ||
| |> function1(...); | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $value = "hello world"; | ||
| $result1 = function3($value); | ||
| $result2 = function2($result1); | ||
| $result = function1($result2); | ||
|
|
||
| ?> |
22 changes: 22 additions & 0 deletions
22
...or/StmtsAwareInterface/DowngradePipeOperatorRectorTest/Fixture/pipe_in_assignment.php.inc
This file contains hidden or 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,22 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $value = " test "; | ||
| $result = $value |> trim(...) |> strtoupper(...); | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $value = " test "; | ||
| $result1 = trim($value); | ||
| $result = strtoupper($result1); | ||
|
|
||
| ?> |
20 changes: 20 additions & 0 deletions
20
...tor/StmtsAwareInterface/DowngradePipeOperatorRectorTest/Fixture/pipe_with_closure.php.inc
This file contains hidden or 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,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $result = "hello" |> (fn($x) => strtoupper($x)) |> (fn($y) => $y . '!'); | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $result1 = (fn($x) => strtoupper($x))("hello"); | ||
| $result = (fn($y) => $y . '!')($result1); | ||
|
|
||
| ?> |
33 changes: 33 additions & 0 deletions
33
...StmtsAwareInterface/DowngradePipeOperatorRectorTest/Fixture/pipe_with_method_call.php.inc
This file contains hidden or 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,33 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| class StringProcessor { | ||
| public function process($str) { | ||
| return trim($str); | ||
| } | ||
| } | ||
|
|
||
| $processor = new StringProcessor(); | ||
| $result = " hello " |> $processor->process(...); | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| class StringProcessor { | ||
| public function process($str) { | ||
| return trim($str); | ||
| } | ||
| } | ||
|
|
||
| $processor = new StringProcessor(); | ||
| $result = $processor->process(" hello "); | ||
|
|
||
| ?> |
21 changes: 21 additions & 0 deletions
21
...wareInterface/DowngradePipeOperatorRectorTest/Fixture/pipe_with_variable_function.php.inc
This file contains hidden or 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,21 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $func = 'trim'; | ||
| $result = " hello " |> $func(...); | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $func = 'trim'; | ||
| $result = $func(" hello "); | ||
|
|
||
| ?> |
19 changes: 19 additions & 0 deletions
19
...85/Rector/StmtsAwareInterface/DowngradePipeOperatorRectorTest/Fixture/simple_pipe.php.inc
This file contains hidden or 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,19 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $result = strtoupper("Hello World") |> trim(...); | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $result = trim(strtoupper("Hello World")); | ||
|
|
||
| ?> |
10 changes: 10 additions & 0 deletions
10
...tor/StmtsAwareInterface/DowngradePipeOperatorRectorTest/Fixture/skip_invalid_pipe.php.inc
This file contains hidden or 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); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| // This should be skipped as the right side is not callable | ||
| $result = "hello" |> "not_callable"; | ||
|
|
||
| ?> |
9 changes: 9 additions & 0 deletions
9
...5/Rector/StmtsAwareInterface/DowngradePipeOperatorRectorTest/Fixture/skip_no_pipe.php.inc
This file contains hidden or 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,9 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector\Fixture; | ||
|
|
||
| $result = trim("hello"); | ||
|
|
||
| ?> |
10 changes: 10 additions & 0 deletions
10
...p85/Rector/StmtsAwareInterface/DowngradePipeOperatorRectorTest/config/configured_rule.php
This file contains hidden or 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\DowngradePhp85\Rector\StmtsAwareInterface\DowngradePipeOperatorRector; | ||
|
|
||
| return static function (RectorConfig $rectorConfig): void { | ||
| $rectorConfig->rule(DowngradePipeOperatorRector::class); | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.