Skip to content

Add HasNamedArguments attribute to validator constraints#28

Merged
veewee merged 1 commit into
phpro:mainfrom
veewee:fix/has-named-arguments-validator-constraints
Apr 16, 2026
Merged

Add HasNamedArguments attribute to validator constraints#28
veewee merged 1 commit into
phpro:mainfrom
veewee:fix/has-named-arguments-validator-constraints

Conversation

@veewee
Copy link
Copy Markdown
Contributor

@veewee veewee commented Apr 16, 2026

Summary

  • Adds #[HasNamedArguments] to SchemaFieldConstraint, TableKeyExistsConstraint, and UniqueConstraint
  • Symfony 7.4 requires this attribute on constraint constructors with typed parameters; without it the YAML loader passes the options array as a single positional argument, causing a TypeError

References

Symfony 7.4 requires the #[HasNamedArguments] attribute on constraint
constructors with typed parameters. Without it, the YAML validator
loader falls back to the deprecated path which passes the entire
options array as the first positional argument, breaking constraints
that expect typed parameters like string $table.

See: https://symfony.com/doc/current/validation/custom_constraint.html
See: https://github.com/symfony/symfony/blob/7.4/CHANGELOG-7.4.md
@veewee veewee merged commit 51791ce into phpro:main Apr 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant