Skip to content

Commit c39a52a

Browse files
authored
Merge pull request #992 from bravik/fix-composite-validation-constraints
Fix type generation for Composite symfony validator with explicit 'constraints' key
2 parents f3b2357 + 8c5c685 commit c39a52a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Generator/TypeBuilder.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,21 @@ protected function buildConstraints(array $constraints = [], bool $inClosure = t
637637
if (isset($args[0]) && is_array($args[0])) {
638638
// Nested instance
639639
$instance->addArgument($this->buildConstraints($args, false));
640+
} elseif (isset($args['constraints'][0]) && is_array($args['constraints'][0])) {
641+
// Nested instance with "constraints" key (full syntax)
642+
$options = [
643+
'constraints' => $this->buildConstraints($args['constraints'], false),
644+
];
645+
646+
// Check for additional options
647+
foreach ($args as $key => $option) {
648+
if ('constraints' === $key) {
649+
continue;
650+
}
651+
$options[$key] = $option;
652+
}
653+
654+
$instance->addArgument($options);
640655
} else {
641656
// Numeric or Assoc array?
642657
$instance->addArgument(isset($args[0]) ? $args : Collection::assoc($args));

0 commit comments

Comments
 (0)