Merge pull request #11 from yoomoney/release/v2.0.5

Release/2.0.5
This commit is contained in:
Anton Nikolaev
2021-01-15 09:22:54 +03:00
committed by GitHub
6 changed files with 42 additions and 6 deletions
+3
View File
@@ -1,3 +1,6 @@
### v2.0.5 от 15.01.2020
* Оптимизация работы с Unicode в json
### v2.0.4 от 28.12.2020
* Оптимизация получения списка платежей
+1 -1
View File
@@ -11,7 +11,7 @@
"email": "cms@yoomoney.ru"
}
],
"version": "2.0.4",
"version": "2.0.5",
"require": {
"php": ">=5.3.0",
"ext-curl": "*",
+1 -1
View File
@@ -90,7 +90,7 @@ class Client extends BaseClient
/**
* Текущая версия библиотеки
*/
const SDK_VERSION = '2.0.4';
const SDK_VERSION = '2.0.5';
/**
* Получить список платежей магазина.
+25 -3
View File
@@ -265,13 +265,35 @@ class BaseClient
return '{}';
}
$result = json_encode($serializedData);
if ($result === false) {
if (defined('JSON_UNESCAPED_UNICODE')) {
$encoded = json_encode($serializedData, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
} else {
$encoded = self::_unescaped(json_encode($serializedData));
}
if ($encoded === false) {
$errorCode = json_last_error();
throw new JsonException("Failed serialize json.", $errorCode);
}
return $result;
return $encoded;
}
/**
* @param string $json
* @return string|false
*/
private static function _unescaped($json)
{
if ($json === false) {
return false;
}
$json = str_replace('\\/', '/', $json);
return preg_replace_callback('/\\\\u(\w{4})/', function ($matches) {
return html_entity_decode('&#x' . $matches[1] . ';', ENT_COMPAT, 'UTF-8');
}, $json);
}
/**
+1 -1
View File
@@ -104,7 +104,7 @@ class ReceiptCustomer extends AbstractObject implements ReceiptCustomerInterface
}
/**
* Устанавливливает номер телефона плательщика в формате ITU-T E.164 на который будет выслан чек
* Устанавливает номер телефона плательщика в формате ITU-T E.164 на который будет выслан чек
*
* @param string $value Номер телефона плательщика в формате ITU-T E.164
*
+11
View File
@@ -1052,6 +1052,17 @@ class ClientTest extends TestCase
->getPaymentInfo(Random::str(36));
}
public function testEncodeMultibyteData()
{
$instance = new TestClient();
$value = array('hello' => 'Привет', 'olleh' => 'سلام');
$result = $instance->encode($value);
self::assertTrue(strpos($result, 'Привет') !== false);
self::assertTrue(strpos($result, 'سلام') !== false);
}
public function testEncodeInvalidData()
{
$instance = new TestClient();