catch ValueError thrown on PHP 8

This commit is contained in:
Christian Flothmann 2020-09-18 11:45:13 +02:00
parent 791761277d
commit fb0d7beaaf

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);