Skip to content

Commit c89511a

Browse files
committed
[DowngradePhp84] Apply on return on DowngradeArrayAnyRector
1 parent c371a23 commit c89511a

File tree

1 file changed

+34
-0
lines changed
  • rules-tests/DowngradePhp84/Rector/Expression/DowngradeArrayAnyRector/Fixture

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Rector\Tests\DowngradePhp84\Rector\Expression\DowngradeArrayAnyRector\Fixture;
4+
5+
class OnReturn
6+
{
7+
public function run(array $animals)
8+
{
9+
return array_any($animals, fn($animal) => str_starts_with($animal, 'c'));
10+
}
11+
}
12+
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\DowngradePhp84\Rector\Expression\DowngradeArrayAnyRector\Fixture;
18+
19+
class OnReturn
20+
{
21+
public function run(array $animals)
22+
{
23+
$found = false;
24+
foreach ($animals as $animal) {
25+
if (str_starts_with($animal, 'c')) {
26+
$found = true;
27+
break;
28+
}
29+
}
30+
return $found;
31+
}
32+
}
33+
34+
?>

0 commit comments

Comments
 (0)