From cdb9fbf679405f32eb421d2209e64bd960a0a858 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 17 Oct 2013 00:36:48 +0400 Subject: [PATCH] Fixes PHP 5.5 weird placeholder replacememt in case no arguments are provided at all (https://bugs.php.net/bug.php?id=65920). --- framework/yii/i18n/MessageFormatter.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/framework/yii/i18n/MessageFormatter.php b/framework/yii/i18n/MessageFormatter.php index c412420..464f3f7 100644 --- a/framework/yii/i18n/MessageFormatter.php +++ b/framework/yii/i18n/MessageFormatter.php @@ -13,6 +13,7 @@ namespace yii\i18n; * - Accepts named arguments and mixed numeric and named arguments. * - Issues no error when an insufficient number of arguments have been provided. Instead, the placeholders will not be * substituted. + * - Fixes PHP 5.5 weird placeholder replacememt in case no arguments are provided at all (https://bugs.php.net/bug.php?id=65920). * * @author Alexander Makarov * @author Carsten Brandt @@ -29,6 +30,10 @@ class MessageFormatter extends \MessageFormatter */ public function format($args) { + if ($args === array()) { + return $this->getPattern(); + } + if (self::needFix()) { $pattern = self::replaceNamedArguments($this->getPattern(), $args); $this->setPattern($pattern); @@ -48,6 +53,10 @@ class MessageFormatter extends \MessageFormatter */ public static function formatMessage($locale, $pattern, $args) { + if ($args === array()) { + return $pattern; + } + if (self::needFix()) { $pattern = self::replaceNamedArguments($pattern, $args); $args = array_values($args);