-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Handle infinite loop on array_reverse with index on…
… AddMethodCallBasedStrictParamTypeRector on php8+ feature (#3678) * [TypeDeclaration] Handle infinite loop on array_reverse with index * [ci-review] Rector Rectify * add fixture for php7.4 as well * fix namespace * [ci-review] Rector Rectify * Fix * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
35ce899
commit be6ca86
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...thod/AddMethodCallBasedStrictParamTypeRector/Fixture/skip_no_return_array_reverse.php.inc
This file contains 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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector\Fixture; | ||
|
||
final class SkipNoReturnArrayReverse | ||
{ | ||
public function run() | ||
{ | ||
$parts = array_reverse(explode('/', '/some/test/url')); | ||
foreach ($parts as $index => $uri) { | ||
if ($index === 0) { | ||
continue; | ||
} | ||
|
||
$this->someOtherMethod($index, $uri); | ||
} | ||
} | ||
|
||
private function someOtherMethod(int $index, string $uri) | ||
{ | ||
return sprintf('%d-%s', $index, $uri); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...AddMethodCallBasedStrictParamTypeRector/FixtureUnion/skip_no_return_array_reverse.php.inc
This file contains 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,23 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector\FixtureUnion; | ||
|
||
final class SkipNoReturnArrayReverse | ||
{ | ||
public function run() | ||
{ | ||
$parts = array_reverse(explode('/', '/some/test/url')); | ||
foreach ($parts as $index => $uri) { | ||
if ($index === 0) { | ||
continue; | ||
} | ||
|
||
$this->someOtherMethod($index, $uri); | ||
} | ||
} | ||
|
||
private function someOtherMethod(int $index, string $uri) | ||
{ | ||
return sprintf('%d-%s', $index, $uri); | ||
} | ||
} |
This file contains 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