diff --git a/src/Descriptors/Values.php b/src/Descriptors/Values.php index 5f3bb31..6b05281 100644 --- a/src/Descriptors/Values.php +++ b/src/Descriptors/Values.php @@ -92,7 +92,7 @@ protected function mixed(null|string|Closure $attribute = null): ValueMixed /** * @param null|string|Closure(T):mixed $attribute * - * @return ValueEnum + * @return ValueEnum */ protected function enum(null|string|Closure $attribute = null): ValueEnum { @@ -110,10 +110,9 @@ protected function struct(Closure $attribute): ValueStruct } /** - * @template U - * @param Value $type + * @param Value $type * @param null|string|Closure(T):(array|null) $attribute - * @return ValueArray + * @return ValueArray */ protected function arrayOf(Value $type, null|string|Closure $attribute = null): ValueArray { diff --git a/src/Descriptors/Values/ValueEnum.php b/src/Descriptors/Values/ValueEnum.php index e5cfc93..bd2e38d 100644 --- a/src/Descriptors/Values/ValueEnum.php +++ b/src/Descriptors/Values/ValueEnum.php @@ -8,10 +8,28 @@ /** * @template T + * @template U extends UnitEnum|BackedEnum * @extends Value */ class ValueEnum extends Value { + /** + * @var class-string|null + */ + protected null|string $type = null; + + /** + * Define the type of elements in the array + * + * @param class-string $type + * @return $this + */ + public function of(string $type): static + { + $this->type = $type; + return $this; + } + protected function value(mixed $of, Request $request): mixed { if ($of instanceof BackedEnum) return $of->value;