[Form] fix passing null $pattern to IntlDateFormatter
MODIFY
DateFormatter/IntlDateFormatter.php
DateFormatter/IntlDateFormatter.php
@@ -145,6 +145,10 @@ abstract class IntlDateFormatter
$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 @@ abstract class IntlDateFormatter
/**
* 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 @@ abstract class IntlDateFormatter
*/
public function setPattern($pattern)
{
- if (null === $pattern) {
- $pattern = $this->getDefaultPattern();
- }
-
- $this->pattern = $pattern;
+ $this->pattern = (string) $pattern;
return true;
}

[Form] fix passing null $pattern to IntlDateFormatter