catch ValueError thrown on PHP 8
authorChristian Flothmann <christian.flothmann@sensiolabs.de>
Fri, 18 Sep 2020 09:45:13 +0000 (11:45 +0200)
committerChristian Flothmann <christian.flothmann@sensiolabs.de>
Fri, 18 Sep 2020 09:45:13 +0000 (11:45 +0200)
src/Symfony/Component/Validator/Constraints/TimezoneValidator.php

index cf52239..ab6b4ee 100644 (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);