Skip to content

Commit ea27d15

Browse files
arshidkv12Arshid
andauthored
MbStrContainsRector (#7199)
* MbStrContainsRector * MbStrContainsRector * MbStrContainsRector * MbStrContainsRector --------- Co-authored-by: Arshid <arshid@Arshids-MacBook-Air.local>
1 parent edfd9f8 commit ea27d15

28 files changed

+821
-35
lines changed

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ parameters:
218218

219219
- '#Register "Rector\\Php81\\Rector\\ClassMethod\\NewInInitializerRector" service to "php81\.php" config set#'
220220

221+
- '#Register "Rector\\Php80\\Rector\\NotIdentical\\MbStrContainsRector" service to "php80\.php" config set#'
222+
221223
# closure detailed
222224
- '#Method Rector\\Config\\RectorConfig\:\:singleton\(\) has parameter \$concrete with no signature specified for Closure#'
223225

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class Fixture
6+
{
7+
public function run()
8+
{
9+
$isMatch = mb_strpos('abc', 'a') !== false;
10+
}
11+
}
12+
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
18+
19+
class Fixture
20+
{
21+
public function run()
22+
{
23+
$isMatch = str_contains('abc', 'a');
24+
}
25+
}
26+
27+
?>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class Fixture
6+
{
7+
public function run()
8+
{
9+
$isMatch = mb_strpos('😊abc', 'a') != false;
10+
}
11+
}
12+
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
18+
19+
class Fixture
20+
{
21+
public function run()
22+
{
23+
$isMatch = str_contains('😊abc', 'a');
24+
}
25+
}
26+
27+
?>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class IdenticalStrpos
6+
{
7+
public function run()
8+
{
9+
$isMatch = mb_strpos('abc😊', 'a') === false;
10+
}
11+
}
12+
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
18+
19+
class IdenticalStrpos
20+
{
21+
public function run()
22+
{
23+
$isMatch = !str_contains('abc😊', 'a');
24+
}
25+
}
26+
27+
?>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class IdenticalStrstr
6+
{
7+
public function run()
8+
{
9+
$isMatch = mb_strstr('abc', 'a') == false;
10+
}
11+
}
12+
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
18+
19+
class IdenticalStrstr
20+
{
21+
public function run()
22+
{
23+
$isMatch = !str_contains('abc', 'a');
24+
}
25+
}
26+
27+
?>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class IdenticalStrstr
6+
{
7+
public function run()
8+
{
9+
$isMatch = mb_strstr('abc', 'a') === false;
10+
}
11+
}
12+
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
18+
19+
class IdenticalStrstr
20+
{
21+
public function run()
22+
{
23+
$isMatch = !str_contains('abc', 'a');
24+
}
25+
}
26+
27+
?>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class OffsetStrpos
6+
{
7+
public function run()
8+
{
9+
$isMatch = mb_strpos('abc', 'a', 1) != false;
10+
}
11+
}
12+
?>
13+
-----
14+
<?php
15+
16+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
17+
18+
class OffsetStrpos
19+
{
20+
public function run()
21+
{
22+
$isMatch = str_contains(mb_substr('abc', 1), 'a');
23+
}
24+
}
25+
?>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class OffsetExpressionStrpos
6+
{
7+
public function run()
8+
{
9+
$offset = 1;
10+
$isMatch = mb_strpos('abc', 'a', $offset + 1) != false;
11+
}
12+
}
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
18+
19+
class OffsetExpressionStrpos
20+
{
21+
public function run()
22+
{
23+
$offset = 1;
24+
$isMatch = str_contains(mb_substr('abc', $offset + 1), 'a');
25+
}
26+
}
27+
?>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class OffsetExpressionStrpos
6+
{
7+
public function run()
8+
{
9+
$offset = 1;
10+
$isMatch = mb_strpos('abc', 'a', $offset + 1) !== false;
11+
}
12+
}
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
18+
19+
class OffsetExpressionStrpos
20+
{
21+
public function run()
22+
{
23+
$offset = 1;
24+
$isMatch = str_contains(mb_substr('abc', $offset + 1), 'a');
25+
}
26+
}
27+
?>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
4+
5+
class OffsetNegativeStrpos
6+
{
7+
public function run()
8+
{
9+
$isMatch = mb_strpos('abc', 'a', -1) != false;
10+
}
11+
}
12+
?>
13+
-----
14+
<?php
15+
16+
namespace Rector\Tests\Php80\Rector\NotIdentical\MbStrContainsRector\Fixture;
17+
18+
class OffsetNegativeStrpos
19+
{
20+
public function run()
21+
{
22+
$isMatch = str_contains(mb_substr('abc', -1), 'a');
23+
}
24+
}
25+
?>

0 commit comments

Comments
 (0)