Configurable

SpatieEnumClassToEnumRector

Refactor Spatie enum class to native Enum

-use \Spatie\Enum\Enum;
-
-/**
- * @method static self draft()
- * @method static self published()
- * @method static self archived()
- */
-class StatusEnum extends Enum
+enum StatusEnum : string
 {
+    case DRAFT = 'draft';
+    case PUBLISHED = 'published';
+    case ARCHIVED = 'archived';
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector;

return RectorConfig::configure()
    ->withConfiguredRule(SpatieEnumClassToEnumRector::class, [
        'toUpperSnakeCase' => false,
    ]);
SETS:  PHP 8.1