diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 4d7eed8b0c437..8d73404b5d1b0 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -172,7 +172,7 @@ protected function getIntlDateFormatter($ignoreTimezone = false) $calendar = $this->calendar; $pattern = $this->pattern; - $intlDateFormatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, $timezone, $calendar, $pattern); + $intlDateFormatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, $timezone, $calendar, $pattern ?? ''); // new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/66323 if (!$intlDateFormatter) { diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index e446151d2a54d..0a20d94e66df1 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -51,14 +51,14 @@ public function buildForm(FormBuilderInterface $builder, array $options) $dateFormat = \is_int($options['format']) ? $options['format'] : self::DEFAULT_FORMAT; $timeFormat = \IntlDateFormatter::NONE; $calendar = \IntlDateFormatter::GREGORIAN; - $pattern = \is_string($options['format']) ? $options['format'] : null; + $pattern = \is_string($options['format']) ? $options['format'] : ''; if (!\in_array($dateFormat, self::$acceptedFormats, true)) { throw new InvalidOptionsException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom format.'); } if ('single_text' === $options['widget']) { - if (null !== $pattern && false === strpos($pattern, 'y') && false === strpos($pattern, 'M') && false === strpos($pattern, 'd')) { + if ('' !== $pattern && false === strpos($pattern, 'y') && false === strpos($pattern, 'M') && false === strpos($pattern, 'd')) { throw new InvalidOptionsException(sprintf('The "format" option should contain the letters "y", "M" or "d". Its current value is "%s".', $pattern)); } @@ -71,7 +71,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $pattern )); } else { - if (null !== $pattern && (false === strpos($pattern, 'y') || false === strpos($pattern, 'M') || false === strpos($pattern, 'd'))) { + if ('' !== $pattern && (false === strpos($pattern, 'y') || false === strpos($pattern, 'M') || false === strpos($pattern, 'd'))) { throw new InvalidOptionsException(sprintf('The "format" option should contain the letters "y", "M" and "d". Its current value is "%s".', $pattern)); } diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index d77c094117cc0..317510c2368fe 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -145,6 +145,10 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti $this->datetype = null !== $datetype ? $datetype : self::FULL; $this->timetype = null !== $timetype ? $timetype : self::FULL; + if ('' === ($pattern ?? '')) { + $pattern = $this->getDefaultPattern(); + } + $this->setPattern($pattern); $this->setTimeZone($timezone); } @@ -485,7 +489,7 @@ public function setLenient($lenient) /** * Set the formatter's pattern. * - * @param string|null $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation + * @param string $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation * * @return bool true on success or false on failure * @@ -494,11 +498,7 @@ public function setLenient($lenient) */ public function setPattern($pattern) { - if (null === $pattern) { - $pattern = $this->getDefaultPattern(); - } - - $this->pattern = $pattern; + $this->pattern = (string) $pattern; return true; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy