Fix for deprecations from Symfony Validator 7.4#49
Conversation
Replace positional argument with named argument 'choices:' in all Choice constraint usages to fix Symfony 7.4 deprecation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: robjenman <767666+robjenman@users.noreply.github.com>
…-validator Use named `choices` argument in Choice constraint for Symfony 7.4 compat
There was a problem hiding this comment.
Pull request overview
This PR updates Symfony Validator constraint attributes to address deprecations surfaced by Symfony Validator 7.4, primarily by switching Choice usages to the named choices: argument and by explicitly setting the Url constraint’s requireTld option.
Changes:
- Replace
#[Choice([...])]/new Choice([...])with#[Choice(choices: [...])]/new Choice(choices: [...])across Google/Apple pass DTOs. - Update
#[Url]usages to#[Url(requireTld: true)]to avoid Symfony 7.4 deprecation warnings.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Google/Passes/TransitObject.php | Update Choice attribute to use choices: named argument. |
| src/Google/Passes/TransitClass.php | Update Choice attribute to use choices: named argument. |
| src/Google/Passes/OfferClass.php | Update Choice attribute to use choices: named argument. |
| src/Google/Passes/GenericObject.php | Update Choice attribute to use choices: named argument. |
| src/Google/Passes/FlightClass.php | Update Choice attribute to use choices: named argument. |
| src/Google/Passes/EventTicketClass.php | Update multiple Choice attributes to use choices: named argument. |
| src/Google/Passes/BaseClass.php | Update Choice attribute to use choices: named argument. |
| src/Google/Passes/AbstractObject.php | Update Choice attribute to use choices: named argument. |
| src/Google/Passes/AbstractClass.php | Update Choice attributes to use choices: named argument. |
| src/Google/Components/Transit/TicketSeat.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Loyalty/DiscoverableProgramMerchantSignupInfo.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Loyalty/DiscoverableProgram.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Flight/BoardingAndSeatingPolicy.php | Update Choice attributes to use choices: named argument. |
| src/Google/Components/Flight/BoardingAndSeatingInfo.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/EventTicket/EventDateTime.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Common/TotpDetails.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Common/SecurityAnimation.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Common/RotatingBarcode.php | Update Choice attributes to use choices: named argument. |
| src/Google/Components/Common/Message.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Common/ClassTemplate/TemplateItem.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Common/ClassTemplate/FirstRowOption.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Common/ClassTemplate/FieldReference.php | Update Choice attribute to use choices: named argument. |
| src/Google/Components/Common/CallbackOptions.php | Set Url(requireTld: true) explicitly on callback URLs. |
| src/Google/Components/Common/Barcode.php | Update Choice attributes to use choices: named argument. |
| src/Apple/Passes/Pass.php | Set Url(requireTld: true) explicitly on webServiceURL. |
| src/Apple/Passes/BoardingPass.php | Update Choice attribute to use choices: named argument. |
| src/Apple/Components/Semantics.php | Update Choice attribute to use choices: named argument. |
| src/Apple/Components/SecondaryField.php | Update Choice attribute to use choices: named argument. |
| src/Apple/Components/Field.php | Update Choice (and nested new Choice) to use choices: named argument. |
| src/Apple/Components/Barcode.php | Update Choice attribute to use choices: named argument. |
| src/Apple/Components/AuxiliaryField.php | Update Choice attribute to use choices: named argument. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[NotBlank] | ||
| #[Url] | ||
| #[Url(requireTld: true)] | ||
| public string $url, | ||
| /** |
There was a problem hiding this comment.
Setting requireTld: true changes validation semantics vs the default (it will reject hosts like localhost or internal DNS names). If this change is only to silence the Symfony 7.4 deprecation, consider explicitly choosing the value that preserves existing behavior (or document the breaking change). Also, the docblock says the URL must be HTTPS, but Url without protocols: ['https'] still accepts http://.
| */ | ||
| #[Url] | ||
| #[Url(requireTld: true)] | ||
| public ?string $updateRequestUrl = null, |
There was a problem hiding this comment.
Same concern as url: requireTld: true may be a breaking validation change (e.g., rejects https://localhost/...). If keeping prior behavior is important, set requireTld explicitly to the intended value and consider adding a focused test to lock that behavior in.
| * @see https://developer.apple.com/library/archive/documentation/PassKit/Reference/PassKit_WebService/WebService.html#//apple_ref/doc/uid/TP40011988 | ||
| */ | ||
| #[Url] | ||
| #[Url(requireTld: true)] |
There was a problem hiding this comment.
requireTld: true is a behavior change for URL validation (it rejects localhost/intranet hosts). If this is only meant to address the Symfony 7.4 deprecation, consider setting requireTld to the value that matches previous releases (or document the stricter validation and add a test for it).
| #[Url(requireTld: true)] | |
| #[Url(requireTld: false)] |
|
This PR should also update to symfony validator 8 |
No description provided.