Skip to content
Permalink
Browse files

Fixes #2707

When the first variable argument = null, but there are more arguments given.
Added testcases to show the change (to fail before the fix)
  • Loading branch information...
hmic committed Aug 24, 2014
1 parent 8f420d7 commit b4620b4c6ca4fab65802ce35468c642049d745f9
Showing with 15 additions and 7 deletions.
  1. +8 −0 lib/Cake/Test/Case/BasicsTest.php
  2. +7 −7 lib/Cake/basics.php
@@ -380,6 +380,14 @@ public function testTranslate() {
$expected = 'Some string with multiple arguments';
$this->assertEquals($expected, $result);
$result = __('Some string with %s and a null argument', null);
$expected = 'Some string with %s and a null argument';
$this->assertEquals($expected, $result);
$result = __('Some string with multiple %s%s, first beeing null', null, 'arguments');
$expected = 'Some string with multiple arguments, first beeing null';
$this->assertEquals($expected, $result);
$result = __('Some string with %s %s', array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments';
$this->assertEquals($expected, $result);
@@ -554,7 +554,7 @@ function __($singular, $args = null) {
App::uses('I18n', 'I18n');
$translated = I18n::translate($singular);
if ($args === null) {
if ($args === null && func_num_args() < 3) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 1);
@@ -586,7 +586,7 @@ function __n($singular, $plural, $count, $args = null) {
App::uses('I18n', 'I18n');
$translated = I18n::translate($singular, $plural, null, I18n::LC_MESSAGES, $count);
if ($args === null) {
if ($args === null && func_num_args() < 5) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 3);
@@ -615,7 +615,7 @@ function __d($domain, $msg, $args = null) {
}
App::uses('I18n', 'I18n');
$translated = I18n::translate($msg, null, $domain);
if ($args === null) {
if ($args === null && func_num_args() < 4) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 2);
@@ -648,7 +648,7 @@ function __dn($domain, $singular, $plural, $count, $args = null) {
}
App::uses('I18n', 'I18n');
$translated = I18n::translate($singular, $plural, $domain, I18n::LC_MESSAGES, $count);
if ($args === null) {
if ($args === null && func_num_args() < 6) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 4);
@@ -692,7 +692,7 @@ function __dc($domain, $msg, $category, $args = null) {
}
App::uses('I18n', 'I18n');
$translated = I18n::translate($msg, null, $domain, $category);
if ($args === null) {
if ($args === null && func_num_args() < 5) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 3);
@@ -740,7 +740,7 @@ function __dcn($domain, $singular, $plural, $count, $category, $args = null) {
}
App::uses('I18n', 'I18n');
$translated = I18n::translate($singular, $plural, $domain, $category, $count);
if ($args === null) {
if ($args === null && func_num_args() < 7) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 5);
@@ -780,7 +780,7 @@ function __c($msg, $category, $args = null) {
}
App::uses('I18n', 'I18n');
$translated = I18n::translate($msg, null, null, $category);
if ($args === null) {
if ($args === null && func_num_args() < 4) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 2);

0 comments on commit b4620b4

Please sign in to comment.
You can’t perform that action at this time.