-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Renaming][PostRector] Handle skip path after defined at RenameClassR…
…ector (#3243)
- Loading branch information
1 parent
72bd75f
commit c546aa7
Showing
6 changed files
with
103 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
15 changes: 15 additions & 0 deletions
15
packages/PostRector/Contract/Rector/PostRectorDependencyInterface.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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\PostRector\Contract\Rector; | ||
|
||
use Rector\Core\Contract\Rector\RectorInterface; | ||
|
||
interface PostRectorDependencyInterface | ||
{ | ||
/** | ||
* @return class-string<RectorInterface>[] | ||
*/ | ||
public function getRectorDependencies(): array; | ||
} |
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
7 changes: 7 additions & 0 deletions
7
...Renaming/Rector/Name/RenameClassRector/FixtureSkipAfterDefined/skip_after_defined.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,7 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector\Fixture; | ||
|
||
class SkipAfterDefined extends \Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\OldClass | ||
{ | ||
} |
33 changes: 33 additions & 0 deletions
33
rules-tests/Renaming/Rector/Name/RenameClassRector/SkipAfterDefinedTest.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector; | ||
|
||
use Iterator; | ||
use Rector\Renaming\Rector\Name\RenameClassRector; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
/** | ||
* @see RenameClassRector | ||
*/ | ||
final class SkipAfterDefinedTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureSkipAfterDefined'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/skip_after_defined_configured_rule.php'; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ests/Renaming/Rector/Name/RenameClassRector/config/skip_after_defined_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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Renaming\Rector\Name\RenameClassRector; | ||
use Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\NewClass; | ||
use Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\OldClass; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig | ||
->ruleWithConfiguration(RenameClassRector::class, [ | ||
OldClass::class => NewClass::class, | ||
]); | ||
|
||
// skip the path after defined | ||
$rectorConfig->skip([ | ||
RenameClassRector::class => [sys_get_temp_dir() . '/rector/tests_fixture_'], | ||
]); | ||
}; |