Safer way to prevent the array to string notice.

This commit is contained in:
Phally 2013-09-01 06:16:10 +02:00
parent 84c980f1f4
commit 4f91465af7

View file

@ -553,7 +553,7 @@ class I18n {
$currentToken = $parts[0]; $currentToken = $parts[0];
$value = $parts[1]; $value = $parts[1];
} elseif ($count == 1) { } elseif ($count == 1) {
$value .= $parts[0]; $value = is_array($value) ? $parts[0] : $value . $parts[0];
} else { } else {
continue; continue;
} }
@ -575,15 +575,11 @@ class I18n {
$val = str_replace($replacements, $mustEscape, $val); $val = str_replace($replacements, $mustEscape, $val);
$value[$i] = $val; $value[$i] = $val;
} }
$value = array_filter($value);
if (count($value) == 1) { if (count($value) == 1) {
$definitions[$currentToken] = array_pop($value); $definitions[$currentToken] = array_pop($value);
} else { } else {
$definitions[$currentToken] = $value; $definitions[$currentToken] = $value;
} }
if (empty($value)) {
$value = '';
}
} }
return $definitions; return $definitions;