-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Deprecate validating DateTimeInterface in Date|Time|DateTime constraints #25015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
} | ||
|
||
if ($value instanceof \DateTimeInterface) { | ||
@trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.1 and will throw an exception in 5.0. Use "%s" instead.', DateTime::class, Type::class), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since Symfony 4.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4.2 now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a note in the CHANGELOG/UPGRADE files?
} | ||
|
||
if ($value instanceof \DateTimeInterface) { | ||
@trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.1 and will throw an exception in 5.0. Use "%s" instead.', DateTime::class, Type::class), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4.2 now :)
} | ||
|
||
if ($value instanceof \DateTimeInterface) { | ||
@trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.1 and will throw an exception in 5.0. Use "%s" instead.', Date::class, Type::class), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
} | ||
|
||
if ($value instanceof \DateTimeInterface) { | ||
@trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.1 and will throw an exception in 5.0. Use "%s" instead.', DateTime::class, Type::class), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested alternative could also be to remove the constraint if you always have a \DateTimeInterface|null
in your property, not especially to add a Type
constraint, as this constraint is a no-op for DateTimeInterface
Updated. |
Thank you @ro0NL. |
…Date|Time|DateTime constraints (ro0NL) This PR was merged into the 4.2-dev branch. Discussion ---------- [Validator] Deprecate validating DateTimeInterface in Date|Time|DateTime constraints | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #11925 | License | MIT | Doc PR | symfony/symfony-docs#7583 (old PR but not really needed now) Easy version of #21905. I think individual naming has value. Also the goal is to move forward to use `Type` really, not to bother with constraint renames. Commits ------- 5454e6f [Validator] Deprecate validating DateTimeInterface in Date|Time|DateTime constraints
…dators (ro0NL) This PR was squashed before being merged into the master branch (closes #10302). Discussion ---------- Remove \DateTimeInterface reference from constraint validators See symfony/symfony#25015 Commits ------- 47b5917 Remove \DateTimeInterface reference from constraint validators
…ors (ro0NL) This PR was merged into the 5.0-dev branch. Discussion ---------- [Validator] Remove DateTime support in date/time validators | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> See #25015 Commits ------- 37c1cbb [Validator] Remove DateTime support in date/time validators
Easy version of #21905. I think individual naming has value. Also the goal is to move forward to use
Type
really, not to bother with constraint renames.