From e15689c455dea02d2739e39032da700c80805b46 Mon Sep 17 00:00:00 2001 From: James Hulse Date: Wed, 28 Aug 2024 15:15:01 +1200 Subject: [PATCH 1/2] 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); From c3000cb46d1cc0a5e4d1e98de32d81506cd1d783 Mon Sep 17 00:00:00 2001 From: James Hulse Date: Wed, 28 Aug 2024 15:18:04 +1200 Subject: [PATCH 2/2] Update EnumTransformer.php --- src/Transformers/EnumTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Transformers/EnumTransformer.php b/src/Transformers/EnumTransformer.php index 0523d66..1872ad5 100644 --- a/src/Transformers/EnumTransformer.php +++ b/src/Transformers/EnumTransformer.php @@ -31,7 +31,7 @@ public function transform(ReflectionClass $class, string $name): ?TransformedTyp return null; } - if (empty($enum->getCases()) { + if (empty($enum->getCases())) { return null; }