-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php72][TypeDeclaration] Fix infinite loop on ParseStrWithResultArgum…
…entRector+DeclareStrictTypesRector (#5699) * [Php72][TypeDeclaration] Fix infinite loop on ParseStrWithResultArgumentRector+DeclareStrictTypesRector * [Php72][TypeDeclaration] Fix infinite loop on ParseStrWithResultArgumentRector+DeclareStrictTypesRector * fix * fix * fix * dont use current() * fix phpstan * rename class * rename class
- Loading branch information
1 parent
6225460
commit 13bafcb
Showing
5 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
tests/Issues/InfiniteLoop/DeclareStrictTypesParseStrTest.php
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Issues\InfiniteLoop; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class DeclareStrictTypesParseStrTest extends AbstractRectorTestCase | ||
{ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public static function provideData(): Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/FixtureDeclareStrictTypesParseStr'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/declare_strict_types_parsestr.php'; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/Issues/InfiniteLoop/FixtureDeclareStrictTypesParseStr/namespaced_same_function.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 | ||
|
||
namespace Foo; | ||
|
||
function foo() | ||
{ | ||
return 'foo'; | ||
} | ||
|
||
echo foo(); | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Foo; | ||
|
||
function foo() | ||
{ | ||
return 'foo'; | ||
} | ||
|
||
echo foo(); |
23 changes: 23 additions & 0 deletions
23
.../Issues/InfiniteLoop/FixtureDeclareStrictTypesParseStr/no_namespace_same_function.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 | ||
|
||
function foo() | ||
{ | ||
return 'foo'; | ||
} | ||
|
||
echo foo(); | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
function foo() | ||
{ | ||
return 'foo'; | ||
} | ||
|
||
echo foo(); | ||
|
||
?> |
13 changes: 13 additions & 0 deletions
13
tests/Issues/InfiniteLoop/config/declare_strict_types_parsestr.php
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector; | ||
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; | ||
|
||
return RectorConfig::configure() | ||
->withRules([ | ||
DeclareStrictTypesRector::class, | ||
ParseStrWithResultArgumentRector::class, | ||
]); |