Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test case for STOP_TRAVERSAL directly on refactor (#4185)
* Add failing test case for STOP_TRAVERSAL directly on refactor * [ci-review] Rector Rectify * remove node visitor * use traverseNodesWithCallable * [ci-review] Rector Rectify * cs fix --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
69689c7
commit 9141715
Showing
5 changed files
with
86 additions
and
35 deletions.
There are no files selected for viewing
26 changes: 0 additions & 26 deletions
26
rules/Php55/NodeVisitor/ClassConstStringValueNodeVisitor.php
This file was deleted.
Oops, something went wrong.
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
36 changes: 36 additions & 0 deletions
36
...ngClassNameConstantDefaultValue/Fixture/in_array_constant_with_undefined_variable.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,36 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\StringClassNameConstantDefaultValue\Fixture; | ||
|
||
final class InArrayConstantWithUndefinedVariable | ||
{ | ||
const SKIP_TYPES = [ | ||
'Rector\Tests\Php55\Rector\String_\StringClassNameToClassConstantRector\Source\SomeUser' | ||
]; | ||
|
||
public function run() | ||
{ | ||
echo $undefinedVariableHere; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\StringClassNameConstantDefaultValue\Fixture; | ||
|
||
final class InArrayConstantWithUndefinedVariable | ||
{ | ||
const SKIP_TYPES = [ | ||
'Rector\Tests\Php55\Rector\String_\StringClassNameToClassConstantRector\Source\SomeUser' | ||
]; | ||
|
||
public function run() | ||
{ | ||
$undefinedVariableHere = null; | ||
echo $undefinedVariableHere; | ||
} | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
tests/Issues/StringClassNameConstantDefaultValue/StringClassNameConstantDefaultValueTest.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\Core\Tests\Issues\StringClassNameConstantDefaultValue; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class StringClassNameConstantDefaultValueTest extends AbstractRectorTestCase | ||
{ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public static function provideData(): Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/Issues/StringClassNameConstantDefaultValue/config/configured_rule.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,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; | ||
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rules([ | ||
StringClassNameToClassConstantRector::class, | ||
AddDefaultValueForUndefinedVariableRector::class, | ||
]); | ||
}; |