From e15689c455dea02d2739e39032da700c80805b46 Mon Sep 17 00:00:00 2001 From: James Hulse Date: Wed, 28 Aug 2024 15:15:01 +1200 Subject: [PATCH] Don't generate if an enum has no cases yet --- src/Transformers/EnumTransformer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Transformers/EnumTransformer.php b/src/Transformers/EnumTransformer.php index abd6598..0523d66 100644 --- a/src/Transformers/EnumTransformer.php +++ b/src/Transformers/EnumTransformer.php @@ -31,6 +31,10 @@ public function transform(ReflectionClass $class, string $name): ?TransformedTyp return null; } + if (empty($enum->getCases()) { + return null; + } + return $this->config->shouldTransformToNativeEnums() ? $this->toEnum($enum, $name) : $this->toType($enum, $name);