minor #38231 [Validator] catch ValueError thrown on PHP 8 (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[Validator] catch ValueError thrown on PHP 8

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

see php/php-src@95f4ee38bb

Commits
-------

fb0d7beaaf catch ValueError thrown on PHP 8
This commit is contained in:
Christian Flothmann 2020-09-18 12:06:31 +02:00
commit e299544639

View File

@ -78,7 +78,11 @@ class TimezoneValidator extends ConstraintValidator
private static function getPhpTimezones(int $zone, string $countryCode = null): array
{
if (null !== $countryCode) {
return @\DateTimeZone::listIdentifiers($zone, $countryCode) ?: [];
try {
return @\DateTimeZone::listIdentifiers($zone, $countryCode) ?: [];
} catch (\ValueError $e) {
return [];
}
}
return \DateTimeZone::listIdentifiers($zone);