Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
optimize params and return type
Browse files Browse the repository at this point in the history
  • Loading branch information
justmd5 committed Mar 14, 2022
1 parent a472393 commit c262be3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/Core/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class API extends AbstractAPI
* API constructor.
*
* @param Foundation $app
* @param string $classify
* @param array $filter
* @param string $classify
* @param array $filter
*/
public function __construct(Foundation $app, $classify, $filter)
public function __construct(Foundation $app, string $classify, array $filter)
{
parent::__construct($app);
$this->classify = $classify;
Expand All @@ -41,16 +41,16 @@ public function __construct(Foundation $app, $classify, $filter)
/**
* 请求API.
*
* @param string $method
* @param array $params
* @param array $files
*
* @throws NotFoundException
* @throws IllegalParameterException
* @param string $method
* @param array $params
* @param array $files
*
* @return array
*@throws IllegalParameterException
*
* @throws NotFoundException
*/
public function request($method, $params = [], $files = [])
public function request(string $method, array $params = [], array $files = []): array
{
$url = sprintf('%s/%s/%s_%s', self::BASE_API, $this->classify, $this->classify, strtolower($method));
if (!array_key_exists(strtolower($method), $this->filter)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public function __construct($appId, $secret)
}

/**
* @param array $params
* @param array $params
*
* @return string
*/
public function getReqSign(&$params)
public function getReqSign(array &$params): string
{
$params['app_id'] = $this->appId;
ksort($params);
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Traits/ArgumentProcessingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ trait ArgumentProcessingTrait
{
/**
* @param Signature $signature
* @param array $params
* @param array $params
*
* @return array
*/
public function processParams(Signature $signature, $params)
public function processParams(Signature $signature, array $params): array
{
if (empty($params['nonce_str'])) {
$params['nonce_str'] = md5(uniqid('TencentAi_'));
Expand Down

0 comments on commit c262be3

Please sign in to comment.