mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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)
This commit is contained in:
parent
8f420d74fa
commit
b4620b4c6c
2 changed files with 15 additions and 7 deletions
|
@ -380,6 +380,14 @@ class BasicsTest extends CakeTestCase {
|
||||||
$expected = 'Some string with multiple arguments';
|
$expected = 'Some string with multiple arguments';
|
||||||
$this->assertEquals($expected, $result);
|
$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'));
|
$result = __('Some string with %s %s', array('multiple', 'arguments'));
|
||||||
$expected = 'Some string with multiple arguments';
|
$expected = 'Some string with multiple arguments';
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
|
@ -554,7 +554,7 @@ if (!function_exists('__')) {
|
||||||
|
|
||||||
App::uses('I18n', 'I18n');
|
App::uses('I18n', 'I18n');
|
||||||
$translated = I18n::translate($singular);
|
$translated = I18n::translate($singular);
|
||||||
if ($args === null) {
|
if ($args === null && func_num_args() < 3) {
|
||||||
return $translated;
|
return $translated;
|
||||||
} elseif (!is_array($args)) {
|
} elseif (!is_array($args)) {
|
||||||
$args = array_slice(func_get_args(), 1);
|
$args = array_slice(func_get_args(), 1);
|
||||||
|
@ -586,7 +586,7 @@ if (!function_exists('__n')) {
|
||||||
|
|
||||||
App::uses('I18n', 'I18n');
|
App::uses('I18n', 'I18n');
|
||||||
$translated = I18n::translate($singular, $plural, null, I18n::LC_MESSAGES, $count);
|
$translated = I18n::translate($singular, $plural, null, I18n::LC_MESSAGES, $count);
|
||||||
if ($args === null) {
|
if ($args === null && func_num_args() < 5) {
|
||||||
return $translated;
|
return $translated;
|
||||||
} elseif (!is_array($args)) {
|
} elseif (!is_array($args)) {
|
||||||
$args = array_slice(func_get_args(), 3);
|
$args = array_slice(func_get_args(), 3);
|
||||||
|
@ -615,7 +615,7 @@ if (!function_exists('__d')) {
|
||||||
}
|
}
|
||||||
App::uses('I18n', 'I18n');
|
App::uses('I18n', 'I18n');
|
||||||
$translated = I18n::translate($msg, null, $domain);
|
$translated = I18n::translate($msg, null, $domain);
|
||||||
if ($args === null) {
|
if ($args === null && func_num_args() < 4) {
|
||||||
return $translated;
|
return $translated;
|
||||||
} elseif (!is_array($args)) {
|
} elseif (!is_array($args)) {
|
||||||
$args = array_slice(func_get_args(), 2);
|
$args = array_slice(func_get_args(), 2);
|
||||||
|
@ -648,7 +648,7 @@ if (!function_exists('__dn')) {
|
||||||
}
|
}
|
||||||
App::uses('I18n', 'I18n');
|
App::uses('I18n', 'I18n');
|
||||||
$translated = I18n::translate($singular, $plural, $domain, I18n::LC_MESSAGES, $count);
|
$translated = I18n::translate($singular, $plural, $domain, I18n::LC_MESSAGES, $count);
|
||||||
if ($args === null) {
|
if ($args === null && func_num_args() < 6) {
|
||||||
return $translated;
|
return $translated;
|
||||||
} elseif (!is_array($args)) {
|
} elseif (!is_array($args)) {
|
||||||
$args = array_slice(func_get_args(), 4);
|
$args = array_slice(func_get_args(), 4);
|
||||||
|
@ -692,7 +692,7 @@ if (!function_exists('__dc')) {
|
||||||
}
|
}
|
||||||
App::uses('I18n', 'I18n');
|
App::uses('I18n', 'I18n');
|
||||||
$translated = I18n::translate($msg, null, $domain, $category);
|
$translated = I18n::translate($msg, null, $domain, $category);
|
||||||
if ($args === null) {
|
if ($args === null && func_num_args() < 5) {
|
||||||
return $translated;
|
return $translated;
|
||||||
} elseif (!is_array($args)) {
|
} elseif (!is_array($args)) {
|
||||||
$args = array_slice(func_get_args(), 3);
|
$args = array_slice(func_get_args(), 3);
|
||||||
|
@ -740,7 +740,7 @@ if (!function_exists('__dcn')) {
|
||||||
}
|
}
|
||||||
App::uses('I18n', 'I18n');
|
App::uses('I18n', 'I18n');
|
||||||
$translated = I18n::translate($singular, $plural, $domain, $category, $count);
|
$translated = I18n::translate($singular, $plural, $domain, $category, $count);
|
||||||
if ($args === null) {
|
if ($args === null && func_num_args() < 7) {
|
||||||
return $translated;
|
return $translated;
|
||||||
} elseif (!is_array($args)) {
|
} elseif (!is_array($args)) {
|
||||||
$args = array_slice(func_get_args(), 5);
|
$args = array_slice(func_get_args(), 5);
|
||||||
|
@ -780,7 +780,7 @@ if (!function_exists('__c')) {
|
||||||
}
|
}
|
||||||
App::uses('I18n', 'I18n');
|
App::uses('I18n', 'I18n');
|
||||||
$translated = I18n::translate($msg, null, null, $category);
|
$translated = I18n::translate($msg, null, null, $category);
|
||||||
if ($args === null) {
|
if ($args === null && func_num_args() < 4) {
|
||||||
return $translated;
|
return $translated;
|
||||||
} elseif (!is_array($args)) {
|
} elseif (!is_array($args)) {
|
||||||
$args = array_slice(func_get_args(), 2);
|
$args = array_slice(func_get_args(), 2);
|
||||||
|
|
Loading…
Reference in a new issue