There should be a boolean arrayable flag in the pattern (schema), and if it's true, then ToArray trait should be used in the generated class.
Get rid of DtoSerialize trait in the generated class, because it's already used in the ToArray trait.
Implement PhpDto\Arrayable interface that contains just one method public function toArray(): array.