Skip to content

Commit 37ed8dc

Browse files
[Form] fix passing null $pattern to IntlDateFormatter
1 parent c7c679c commit 37ed8dc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

DateFormatter/IntlDateFormatter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti
145145
$this->datetype = null !== $datetype ? $datetype : self::FULL;
146146
$this->timetype = null !== $timetype ? $timetype : self::FULL;
147147

148+
if ('' === ($pattern ?? '')) {
149+
$pattern = $this->getDefaultPattern();
150+
}
151+
148152
$this->setPattern($pattern);
149153
$this->setTimeZone($timezone);
150154
}
@@ -485,7 +489,7 @@ public function setLenient($lenient)
485489
/**
486490
* Set the formatter's pattern.
487491
*
488-
* @param string|null $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation
492+
* @param string $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation
489493
*
490494
* @return bool true on success or false on failure
491495
*
@@ -494,11 +498,7 @@ public function setLenient($lenient)
494498
*/
495499
public function setPattern($pattern)
496500
{
497-
if (null === $pattern) {
498-
$pattern = $this->getDefaultPattern();
499-
}
500-
501-
$this->pattern = $pattern;
501+
$this->pattern = (string) $pattern;
502502

503503
return true;
504504
}

0 commit comments

Comments
 (0)