-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core][Symfony] Handle crash on get dynamic value ClassConstFetch by …
…method call on ChangeStringCollectionOptionToConstantRector (#2984) * [Core][Symfony] Handle crash on get dynamic value ClassConstFetch by method call on ChangeStringCollectionOptionToConstantRector * Fixed 🎉 * Fixed 🎉 * Fixed 🎉
- Loading branch information
1 parent
888c63c
commit 84a720b
Showing
4 changed files
with
63 additions
and
1 deletion.
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
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\Issue7536; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
/** | ||
* @see https://github.com/rectorphp/rector/issues/7536 | ||
*/ | ||
final class DynamicExprConstantTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return Iterator<array<string>> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/Issues/Issue7536/Fixture/skip_dynamic_class_const_fetch.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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\Issue7536\Fixture; | ||
|
||
use Symfony\Component\Form\FormInterface; | ||
|
||
class SkipDynamicClassConstFetch | ||
{ | ||
private function pocMethod(FormInterface $childType, FormInterface $parentType) | ||
{ | ||
$parentType->add( | ||
$childType->methodA(), | ||
$childType->methodB()::class | ||
); | ||
} | ||
} |
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Symfony\Rector\MethodCall\ChangeStringCollectionOptionToConstantRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(ChangeStringCollectionOptionToConstantRector::class); | ||
}; |