mirror of https://github.com/rectorphp/rector.git
fix casing of enums
This commit is contained in:
parent
6f164da439
commit
332aad337e
|
@ -8724,9 +8724,9 @@ Refactor Spatie enum class to native Enum
|
|||
-class StatusEnum extends Enum
|
||||
+enum StatusEnum : string
|
||||
{
|
||||
+ case draft = 'draft';
|
||||
+ case published = 'published';
|
||||
+ case archived = 'archived';
|
||||
+ case DRAFT = 'draft';
|
||||
+ case PUBLISHED = 'published';
|
||||
+ case ARCHIVED = 'archived';
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ use Spatie\Enum\Enum;
|
|||
|
||||
enum StatusEnum : string
|
||||
{
|
||||
case draft = 'draft';
|
||||
case published = 'published';
|
||||
case archived = 'archived';
|
||||
case DRAFT = 'draft';
|
||||
case PUBLISHED = 'published';
|
||||
case ARCHIVED = 'archived';
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -55,10 +55,10 @@ final class EnumFactory
|
|||
$enum = new Enum_($shortClassName);
|
||||
|
||||
// constant to cases
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($class);
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class);
|
||||
|
||||
$docBlockMethods = $phpDocInfo?->getTagsByName('@method');
|
||||
if ($docBlockMethods !== null) {
|
||||
$docBlockMethods = $phpDocInfo->getTagsByName('@method');
|
||||
if ($docBlockMethods !== []) {
|
||||
$enum->scalarType = new Identifier('string');
|
||||
|
||||
foreach ($docBlockMethods as $docBlockMethod) {
|
||||
|
@ -85,6 +85,10 @@ final class EnumFactory
|
|||
{
|
||||
/** @var MethodTagValueNode $nodeValue */
|
||||
$nodeValue = $phpDocTagNode->value;
|
||||
return new EnumCase($nodeValue->methodName, $this->builderFactory->val($nodeValue->methodName));
|
||||
|
||||
$enumName = strtoupper($nodeValue->methodName);
|
||||
$enumExpr = $this->builderFactory->val($nodeValue->methodName);
|
||||
|
||||
return new EnumCase($enumName, $enumExpr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,9 +54,9 @@ CODE_SAMPLE
|
|||
<<<'CODE_SAMPLE'
|
||||
enum StatusEnum : string
|
||||
{
|
||||
case draft = 'draft';
|
||||
case published = 'published';
|
||||
case archived = 'archived';
|
||||
case DRAFT = 'draft';
|
||||
case PUBLISHED = 'published';
|
||||
case ARCHIVED = 'archived';
|
||||
}
|
||||
CODE_SAMPLE
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue