Skip to content

Commit 8779276

Browse files
committed
refactor(rename): Update enum names to conventional case
- Renamed enum from Suit to Enum for consistency. - Adjusted case names to follow conventional casing. - Updated references in the fixture to reflect new enum structure.
1 parent 0e5f03c commit 8779276

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@
244244
"@putenv:php",
245245
"$PHP82 vendor/bin/grumphp run --ansi -vv"
246246
],
247-
"jack": "@php vendor/bin/jack --ansi -vv",
248-
"jack:breakpoint": "@jack breakpoint --limit=8",
247+
"jack": "@php -d='error_reporting=E_ALL &~ E_DEPRECATED' vendor/bin/jack",
248+
"jack:breakpoint": "@jack breakpoint --limit=9",
249249
"jack:breakpoint-dev": "@jack:breakpoint --dev",
250250
"jack:open-versions": "@jack open-versions --limit=99",
251251
"jack:open-versions-dev": "@jack:open-versions --dev",

src/Rector/Name/RenameToConventionalCaseNameRector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ private function shouldUcfirstCamelName(Node $node): bool
547547
Trait_::class,
548548
// enum EnumName{}
549549
Enum_::class,
550-
// enum Enum{case CaseName;}
551-
EnumCase::class,
550+
// // enum Enum{case CaseName;}
551+
// EnumCase::class,
552552
])
553553
) {
554554
return true;
@@ -653,6 +653,8 @@ private function shouldUpperSnakeName(Node $node): bool
653653
Const_::class,
654654
// Foo::CONST_NAME;
655655
ClassConstFetch::class,
656+
// enum Enum{case CASE_NAME;}
657+
EnumCase::class,
656658
])
657659
) {
658660
return true;

tests/Rector/AbstractRectorTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ final public static function provideCases(): iterable
9292
{
9393
yield from self::yieldFilesFromDirectory(static::directory().'/Fixture/');
9494

95-
foreach ((array) glob(static::directory().'/Fixture[0-9]*/', \GLOB_ONLYDIR) as $directory) {
95+
foreach ((array) glob(static::directory().'/Fixture\d*/', \GLOB_ONLYDIR) as $directory) {
9696
if ((int) (\PHP_MAJOR_VERSION.\PHP_MINOR_VERSION) >= (int) (string) Str::of($directory)->basename()->substr(7)) {
9797
yield from self::yieldFilesFromDirectory($directory);
9898
}

tests/Rector/Name/RenameToConventionalCaseNameRector/Fixture81/fixture.php.inc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
/** @noinspection ALL */
44
// @formatter:off
55
// phpcs:ignoreFile
6-
enum Suit: string
6+
enum Enum: string
77
{
8-
case Heart = 'Heart';
9-
case Diamond = 'Diamond';
10-
case Club = 'Club';
8+
case CaseName = 'CaseName';
119
}
12-
Suit::Heart;
10+
Enum::CaseName;
1311

1412
?>
1513
-----
@@ -18,12 +16,10 @@ Suit::Heart;
1816
/** @noinspection ALL */
1917
// @formatter:off
2018
// phpcs:ignoreFile
21-
enum Suit: string
19+
enum Enum: string
2220
{
23-
case Heart = 'Heart';
24-
case Diamond = 'Diamond';
25-
case Club = 'Club';
21+
case CASE_NAME = 'CaseName';
2622
}
27-
Suit::HEART;
23+
Enum::CASE_NAME;
2824

2925
?>

0 commit comments

Comments
 (0)