-
-
Notifications
You must be signed in to change notification settings - Fork 431
[StrContainsRector] also replace multibyte functions fro strpos and strstr #6905
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 all commits
Commits
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
25 changes: 25 additions & 0 deletions
25
...tests/Php80/Rector/NotIdentical/StrContainsRector/Fixture/multibyte_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\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class MultibyteOffsetStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('happy 😊 euro €', 'e', 8) !== false; | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class MultibyteOffsetStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains(mb_substr('happy 😊 euro €', 8), 'e'); | ||
| } | ||
| } | ||
| ?> |
27 changes: 27 additions & 0 deletions
27
...sts/Php80/Rector/NotIdentical/StrContainsRector/Fixture/multibyte_strpos_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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class MultibyteStrposFunction | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('happy 😊 euro €', 'a') !== false; | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class MultibyteStrposFunction | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains('happy 😊 euro €', 'a'); | ||
| } | ||
| } | ||
|
|
||
| ?> |
27 changes: 27 additions & 0 deletions
27
...sts/Php80/Rector/NotIdentical/StrContainsRector/Fixture/multibyte_strstr_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,27 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class MultibyteStrstrFunction | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strstr('happy 😊 euro €', 'a') === false; | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class MultibyteStrstrFunction | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = !str_contains('happy 😊 euro €', 'a'); | ||
| } | ||
| } | ||
|
|
||
| ?> |
27 changes: 27 additions & 0 deletions
27
...tor/NotIdentical/StrContainsRector/Fixture/offset_variable_equal_multibyte_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\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class OffsetVariableMultibyteStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = mb_strpos('happy 😊 euro €', 'a', $offset) != false; | ||
| } | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class OffsetVariableMultibyteStrpos | ||
| { | ||
| public function run() | ||
| { | ||
| $offset = 1; | ||
| $isMatch = str_contains(mb_substr('happy 😊 euro €', $offset), 'a'); | ||
| } | ||
| } | ||
| ?> |
27 changes: 27 additions & 0 deletions
27
...otIdentical/StrContainsRector/Fixture/replace_multibyte_strpos_with_encoding_null.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\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class ReplaceMultibyteStrposWithEncodingNull | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('happy 😊 euro €', 'a', 0, null) !== false; | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class ReplaceMultibyteStrposWithEncodingNull | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains('happy 😊 euro €', 'a'); | ||
| } | ||
| } | ||
|
|
||
| ?> |
27 changes: 27 additions & 0 deletions
27
...otIdentical/StrContainsRector/Fixture/replace_multibyte_strstr_with_encoding_null.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\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class ReplaceMultibyteStrstrWithEncodingNull | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strstr('happy 😊 euro €', 'a', false, null) !== false; | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class ReplaceMultibyteStrstrWithEncodingNull | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = str_contains('happy 😊 euro €', 'a'); | ||
| } | ||
| } | ||
|
|
||
| ?> |
13 changes: 13 additions & 0 deletions
13
...Rector/NotIdentical/StrContainsRector/Fixture/skip_multibyte_strpos_with_encoding.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,13 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class SkipMultibyteStrposWithEncoding | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strpos('happy 😊 euro €', 'a', 0, 'UTF-8') !== false; | ||
| } | ||
| } | ||
|
|
||
| ?> |
13 changes: 13 additions & 0 deletions
13
...otIdentical/StrContainsRector/Fixture/skip_multibyte_strstr_with_dynamic_encoding.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,13 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class SkipMultibyteStrstrWithDynamicEncoding | ||
| { | ||
| public function run(?string $encoding = 'UTF-8') | ||
| { | ||
| $isMatch = mb_strstr('happy 😊 euro €', 'a', false, $encoding) !== false; | ||
| } | ||
| } | ||
|
|
||
| ?> |
13 changes: 13 additions & 0 deletions
13
...Rector/NotIdentical/StrContainsRector/Fixture/skip_multibyte_strstr_with_encoding.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,13 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\Fixture; | ||
|
|
||
| class SkipMultibyteStrstrWithEncoding | ||
| { | ||
| public function run() | ||
| { | ||
| $isMatch = mb_strstr('happy 😊 euro €', 'a', false, 'UTF-8') !== false; | ||
| } | ||
| } | ||
|
|
||
| ?> |
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
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.