Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove collector interface and fix SpatieEnumClassToEnumRector alread…
…y has underscore to double underscore (#5473) * remove CollectorInterface tagging * regenerate docs * [ci-review] Rector Rectify * remove Collector interface * fix hard to read assignment * [ci-review] Rector Rectify * update test * update test * fix multi underscore on Enum * move value to constant --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
ee89fb7
commit 07df7dc
Showing
12 changed files
with
98 additions
and
97 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
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
33 changes: 33 additions & 0 deletions
33
.../SpatieEnumClassToEnumRector/FixtureUpperCaseSnakeCase/enum_with_camel_case_names.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,33 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\Class_\FixtureUpperCaseSnakeCase\FixtureUpperCaseSnakeCase; | ||
|
||
use Spatie\Enum\Enum; | ||
|
||
/** | ||
* @method static self isOK() | ||
* @method static self needsReview() | ||
* @method static self isV2() | ||
* @method static self IS_OBSOLETE() | ||
*/ | ||
class StatusEnum extends Enum | ||
{ | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\Class_\FixtureUpperCaseSnakeCase\FixtureUpperCaseSnakeCase; | ||
|
||
use Spatie\Enum\Enum; | ||
|
||
enum StatusEnum : string | ||
{ | ||
case IS_OK = 'isOK'; | ||
case NEEDS_REVIEW = 'needsReview'; | ||
case IS_V_2 = 'isV2'; | ||
case IS_OBSOLETE = 'IS_OBSOLETE'; | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
rules-tests/Php81/Rector/Class_/SpatieEnumClassToEnumRector/UpperCaseSnakeCaseTest.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\Php81\Rector\Class_\SpatieEnumClassToEnumRector; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class UpperCaseSnakeCaseTest extends AbstractRectorTestCase | ||
{ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public static function provideData(): Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/FixtureUpperCaseSnakeCase'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule_uppercase_snake_case.php'; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...Rector/Class_/SpatieEnumClassToEnumRector/config/configured_rule_uppercase_snake_case.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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->ruleWithConfiguration(SpatieEnumClassToEnumRector::class, [ | ||
SpatieEnumClassToEnumRector::TO_UPPER_SNAKE_CASE => true, | ||
]); | ||
}; |
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
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
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
This file was deleted.
Oops, something went wrong.