diff --git a/src/BasicService/Jssdk/Client.php b/src/BasicService/Jssdk/Client.php index 8a94c8075..611d3b415 100644 --- a/src/BasicService/Jssdk/Client.php +++ b/src/BasicService/Jssdk/Client.php @@ -73,7 +73,7 @@ public function getConfigArray(array $apis, bool $debug = false, bool $beta = fa * @param bool $refresh * @param string $type * - * @return array + * @return array|null */ public function getTicket(bool $refresh = false, string $type = 'jsapi'): array { @@ -129,7 +129,7 @@ protected function configSignature(string $url = null, string $nonce = null, $ti */ public function getTicketSignature($ticket, $nonce, $timestamp, $url): string { - return sha1("jsapi_ticket={$ticket}&noncestr={$nonce}×tamp={$timestamp}&url={$url}"); + return sha1(sprintf('jsapi_ticket=%s&noncestr=%s×tamp=%s&url=%s', $ticket, $nonce, $timestamp, $url)); } /** @@ -141,7 +141,7 @@ public function dictionaryOrderSignature() sort($params, SORT_STRING); - return sha1(implode($params)); + return sha1(implode('', $params)); } /** diff --git a/tests/BasicService/Jssdk/ClientTest.php b/tests/BasicService/Jssdk/ClientTest.php index 1772b8dc5..daa6296c9 100644 --- a/tests/BasicService/Jssdk/ClientTest.php +++ b/tests/BasicService/Jssdk/ClientTest.php @@ -159,7 +159,7 @@ public function testDictionaryOrderSignature() sort($params, SORT_STRING); - $this->assertSame(sha1(implode($params)), $client->dictionaryOrderSignature(...$unsorted)); + $this->assertSame(sha1(implode('', $params)), $client->dictionaryOrderSignature(...$unsorted)); } public function testUrlSetterAndGetter()