8000 Fixed some issue · symfony/symfony@e89ef2f · GitHub
[go: up one dir, main page]

Skip to content

Commit e89ef2f

Browse files
committed
Fixed some issue
1 parent e0f2d79 commit e89ef2f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Symfony/Component/Translation/Formatter/IntlMessageFormatter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ class IntlMessageFormatter implements MessageFormatterInterface, ChoiceMessageFo
2222
*/
2323
public function format($message, $locale, array $parameters = array())
2424
{
25-
$formatter = new \MessageFormatter($locale, $message);
25+
try {
26+
$formatter = new \MessageFormatter($locale, $message);
27+
} catch (\Throwable $e) {
28+
throw new \InvalidArgumentException('Invalid message format.', $e);
29+
}
2630
if (null === $formatter) {
2731
throw new \InvalidArgumentException(sprintf('Invalid message format. Reason: %s (error #%d)', intl_get_error_message(), intl_get_error_code()));
2832
}

src/Symfony/Component/Translation/Tests/Formatter/IntlMessageFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testFormat($expected, $message, $arguments)
3434

3535
public function testFormatWithNamedArguments()
3636
{
37-
if (PHP_VERSION_ID < 50500 || version_compare(INTL_ICU_VERSION, '4.8', '<')) {
37+
if (version_compare(INTL_ICU_VERSION, '4.8', '<')) {
3838
$this->markTestSkipped('Format with named arguments can only be run with ICU 4.8 or higher and PHP >= 5.5');
3939
}
4040

src/Symfony/Component/Translation/Translator.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,6 @@ private function getConfigCacheFactory(): ConfigCacheFactoryInterface
451451
*/
452452
private function getFormatter(string $domain)
453453
{
454-
if (isset($this->formatters[$domain])) {
455-
return $this->formatters[$domain];
456-
}
457-
458-
return $this->formatters['_default'];
454+
return $this->formatters[$domain] ?? $this->formatters['_default'];
459455
}
460456
}

0 commit comments

Comments
 (0)
0