Skip to content

Commit

Permalink
minor #20059 [Validator] drop type-hints for properties where the ´Ty…
Browse files Browse the repository at this point in the history
…pe´ constraint is used (xabbuh)

This PR was merged into the 6.4 branch.

Discussion
----------

[Validator] drop type-hints for properties where the ´Type´ constraint is used

partially revert #18362 as having the native type-hints prevents the `Type` constraint to be applied in a meaningful way (if the types don't match, PHP will error before)

Commits
-------

27a06be drop type-hints for properties where the Type constraint is used
  • Loading branch information
javiereguiluz committed Jul 23, 2024
2 parents a26d9d3 + 27a06be commit ab44ec8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions reference/constraints/Type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ This will check if ``emailAddress`` is an instance of ``Symfony\Component\Mime\A
class Author
{
#[Assert\Type(Address::class)]
protected Address $emailAddress;
protected $emailAddress;
#[Assert\Type('string')]
protected string $firstName;
protected $firstName;
#[Assert\Type(
type: 'integer',
message: 'The value {{ value }} is not a valid {{ type }}.',
)]
protected int $age;
protected $age;
#[Assert\Type(type: ['alpha', 'digit'])]
protected string $accessCode;
protected $accessCode;
}
.. code-block:: yaml
Expand Down

0 comments on commit ab44ec8

Please sign in to comment.