-
Notifications
You must be signed in to change notification settings - Fork 24
DowngradeMbStrContainsRector #331
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 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
557b732
/DowngradeMbStrContainsRector
2402d39
/DowngradeMbStrContainsRector
8b15495
/DowngradeMbStrContainsRector
cdbbf49
/DowngradeMbStrContainsRector
6656092
/DowngradeMbStrContainsRector
081e073
DowngradeMbStrContainsRector
06265a2
DowngradeMbStrContainsRector
257f57a
DowngradeMbStrContainsRector
1e18cd7
DowngradeMbStrContainsRector
1e1806a
DowngradeMbStrContainsRector
7bea52c
DowngradeMbStrContainsRector
cdb3f07
DowngradeMbStrContainsRector
046c1b1
DowngradeMbStrContainsRector
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
28 changes: 28 additions & 0 deletions
28
...dePhp80/Rector/FuncCall/DowngradeMbStrContainsRector/DowngradeMbStrContainsRectorTest.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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector; | ||
|
|
||
| use Iterator; | ||
| use PHPUnit\Framework\Attributes\DataProvider; | ||
| use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
|
||
| final class DowngradeMbStrContainsRectorTest 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'; | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
...DowngradePhp80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/fixture_equal.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class Fixture | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains('😊abc', '😊a'); | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class Fixture | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('😊abc', '😊a') !== false; | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
27 changes: 27 additions & 0 deletions
27
...adePhp80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/identical_mb_strpos.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class IdenticalStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = !str_contains('abc😊', '😊a'); | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class IdenticalStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('abc😊', '😊a') === false; | ||
| } | ||
| } | ||
|
|
||
| ?> |
27 changes: 27 additions & 0 deletions
27
...adePhp80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/not_equal_mb_strstr.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class IdenticalStrstr | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = !str_contains('😊abc', '😊a'); | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class IdenticalStrstr | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('😊abc', '😊a') === false; | ||
| } | ||
| } | ||
|
|
||
| ?> |
27 changes: 27 additions & 0 deletions
27
...ngradePhp80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/not_str_contains.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| final class NoStrContains | ||
| { | ||
| public function run() | ||
| { | ||
| return ! str_contains('😊abc', 'b😊'); | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| final class NoStrContains | ||
| { | ||
| public function run() | ||
| { | ||
| return mb_strpos('😊abc', 'b😊') === false; | ||
| } | ||
| } | ||
|
|
||
| ?> |
27 changes: 27 additions & 0 deletions
27
...ts/DowngradePhp80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/not_strstr.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class IdenticalStrstr | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = !str_contains('😊abc', '😊a'); | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class IdenticalStrstr | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('😊abc', '😊a') === false; | ||
| } | ||
| } | ||
|
|
||
| ?> |
25 changes: 25 additions & 0 deletions
25
...adePhp80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/offset_equal_strpos.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,25 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains(mb_substr('😊abc', 1), '😊a'); | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('😊abc', '😊a', 1) !== false; | ||
| } | ||
| } | ||
| ?> |
27 changes: 27 additions & 0 deletions
27
...ctor/FuncCall/DowngradeMbStrContainsRector/Fixture/offset_expression_equal_strpos.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetExpressionStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = str_contains(mb_substr('😊abc', $offset + 1), '😊a'); | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetExpressionStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = mb_strpos('😊abc', '😊a', $offset + 1) !== false; | ||
| } | ||
| } | ||
| ?> |
27 changes: 27 additions & 0 deletions
27
.../Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/offset_expression_mb_strpos.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetExpressionStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = str_contains(mb_substr('😊abc', $offset + 1), '😊a'); | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetExpressionStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = mb_strpos('😊abc', '😊a', $offset + 1) !== false; | ||
| } | ||
| } | ||
| ?> |
25 changes: 25 additions & 0 deletions
25
...Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/offset_negative_equal_strpos.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,25 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetNegativeStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains(mb_substr('😊abc', -1), '😊a'); | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetNegativeStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('😊abc', '😊a', -1) !== false; | ||
| } | ||
| } | ||
| ?> |
25 changes: 25 additions & 0 deletions
25
...Php80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/offset_negative_strpos.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,25 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetNegativeStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains(mb_substr('😊abc', -1), '😊a'); | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetNegativeStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('😊abc', '😊a', -1) !== false; | ||
| } | ||
| } | ||
| ?> |
25 changes: 25 additions & 0 deletions
25
...DowngradePhp80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/offset_strpos.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,25 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains(mb_substr('😊abc', 1), '😊a'); | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('😊abc', '😊a', 1) !== false; | ||
| } | ||
| } | ||
| ?> |
27 changes: 27 additions & 0 deletions
27
...Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/offset_variable_equal_strpos.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetVariableStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = str_contains(mb_substr('😊abc', $offset), '😊a'); | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetVariableStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = mb_strpos('😊abc', '😊a', $offset) !== false; | ||
| } | ||
| } | ||
| ?> |
27 changes: 27 additions & 0 deletions
27
...Php80/Rector/FuncCall/DowngradeMbStrContainsRector/Fixture/offset_variable_strpos.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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetVariableStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = str_contains(mb_substr('😊abc', $offset), '😊a'); | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeMbStrContainsRector\Fixture; | ||
|
|
||
| class OffsetVariableStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = mb_strpos('😊abc', '😊a', $offset) !== false; | ||
| } | ||
| } | ||
| ?> |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test fixture to skip no multibyte needle:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the string without multibyte needle.