cases() as $case) { $value = $case instanceof BackedEnum ? $case->value : $case->name; $types[] = ValueTypeFactory::from($value); } $argumentType = UnionType::from(...$types); $this->enum = $type; $this->arguments = new Arguments( new Argument('value', $type->className() . '::$value', $argumentType) ); } public function describeArguments(): Arguments { return $this->arguments; } public function buildObject(array $arguments): object { // @phpstan-ignore offsetAccess.invalidOffset (we know the `value` offset exists) return $this->enum->cases()[$arguments['value']]; } public function signature(): string { return $this->enum->readableSignature(); } }