diff --git a/qq/Recharge.php b/qq/Recharge.php index 6a48c92..3c997c4 100644 --- a/qq/Recharge.php +++ b/qq/Recharge.php @@ -28,9 +28,9 @@ class Recharge extends SmallProgram protected string $host = 'qpay.qq.com'; /** - * @param $value + * @param string $value */ - public function setSpillCreateIp($value) + public function setSpillCreateIp(string $value) { $this->spill_create_ip = $value; } diff --git a/qq/Redhat.php b/qq/Redhat.php index b911571..4965a7d 100644 --- a/qq/Redhat.php +++ b/qq/Redhat.php @@ -284,10 +284,10 @@ class Redhat extends SmallProgram /** - * @param $requestParam + * @param array $requestParam * @return string */ - private function builderSign($requestParam): string + private function builderSign(array $requestParam): string { return Help::sign($requestParam, $this->payConfig->pay->qq->mchSecret, $this->payConfig->getSignType()); } @@ -325,11 +325,11 @@ class Redhat extends SmallProgram /** - * @param $listid - * @param $orderNo + * @param string $listid + * @param string|null $orderNo * @return Result */ - public function searchByOrderNo($listid, $orderNo = null): Result + public function searchByOrderNo(string $listid, ?string $orderNo = null): Result { $requestParam['nonce_str'] = Help::random(31); $requestParam['mch_id'] = $this->payConfig->pay->qq->mchId; diff --git a/qq/pay/Cash_Bonus.php b/qq/pay/Cash_Bonus.php index d1a6e7d..0ae33e8 100644 --- a/qq/pay/Cash_Bonus.php +++ b/qq/pay/Cash_Bonus.php @@ -35,54 +35,53 @@ class Cash_Bonus extends SmallProgram private array $_requestParams = []; /** - * @param $value + * @param string $value */ - public function setMchName($value) + public function setMchName(string $value) { $this->_requestParams['mch_name'] = $value; } /** - * @param $value + * @param string $value */ - public function setActName($value) + public function setActName(string $value) { $this->_requestParams['act_name'] = $value; } /** - * @param $value + * @param string $value */ - public function setWishing($value) + public function setWishing(string $value) { $this->_requestParams['wishing'] = $value; } /** - * @param $value + * @param int $value */ - public function setIconId($value) + public function setIconId(int $value) { $this->_requestParams['icon_id'] = $value; } /** - * @param $value + * @param int $value */ - public function setBannerId($value) + public function setBannerId(int $value) { $this->_requestParams['banner_id'] = $value; } /** - * @param $mch_billno - * @param $openId - * @param $price + * @param string $mch_billno + * @param string $openId + * @param float $price * @return mixed - * @throws Exception */ - public function mch_send($mch_billno, $openId, $price): Result + public function mch_send(string $mch_billno, string $openId, float $price): Result { $client = $this->createClient($this->_cash, $this->orderConfig($mch_billno, $openId, $price)); if (!in_array($client->getStatusCode(), [101, 200, 201])) { @@ -103,12 +102,12 @@ class Cash_Bonus extends SmallProgram } /** - * @param $mch_billno - * @param $openId - * @param $price + * @param string $mch_billno + * @param string $openId + * @param float $price * @return array */ - private function orderConfig($mch_billno, $openId, $price): array + private function orderConfig(string $mch_billno, string $openId, float $price): array { $requestParam['charset'] = 1; $requestParam['nonce_str'] = Help::random(32); diff --git a/qq/pay/Enterprise_payment.php b/qq/pay/Enterprise_payment.php index 3f1f52a..eb8c30d 100644 --- a/qq/pay/Enterprise_payment.php +++ b/qq/pay/Enterprise_payment.php @@ -17,7 +17,7 @@ class Enterprise_payment extends SmallProgram { public string $_cash = '/cgi-bin/epay/qpay_epay_b2c.cgi'; - private $_errors = [ + private array $_errors = [ 'SYSTEMERROR' => '系统错误', 'PARAM_ERROR' => '请求参数未按指引进行填写', 'SIGNERROR' => '参数签名结果不正确', @@ -35,40 +35,39 @@ class Enterprise_payment extends SmallProgram 'INVALID_CERTIFICATE' => '证书非法', ]; - private $_requestParams = []; + private array $_requestParams = []; /** - * @param $value + * @param string $value */ - public function setOpUserId($value) + public function setOpUserId(string $value) { $this->_requestParams['op_user_id'] = $value; } /** - * @param $value + * @param string $value */ - public function setOpUserPassword($value) + public function setOpUserPassword(string $value) { $this->_requestParams['op_user_passwd'] = $value; } /** - * @param $value + * @param string $value */ - public function setSpbillCreateIp($value) + public function setSpbillCreateIp(string $value) { $this->_requestParams['spbill_create_ip'] = $value; } /** - * @param $mch_billno - * @param $openId - * @param $price + * @param string $mch_billno + * @param string $openId + * @param float $price * @return Result - * @throws Exception */ - public function mch_send($mch_billno, $openId, $price): Result + public function mch_send(string $mch_billno, string $openId, float $price): Result { $client = $this->createClient($this->_cash, $this->orderConfig($mch_billno, $openId, $price)); if (!in_array($client->getStatusCode(), [101, 200, 201])) { @@ -85,12 +84,12 @@ class Enterprise_payment extends SmallProgram } /** - * @param $mch_billno - * @param $openId - * @param $price + * @param string $mch_billno + * @param string $openId + * @param float $price * @return array */ - private function orderConfig($mch_billno, $openId, $price): array + private function orderConfig(string $mch_billno, string $openId, float $price): array { $requestParam['input_charset'] = 'UTF-8'; $requestParam['nonce_str'] = Help::random(32); diff --git a/qq/result/RedHatResult.php b/qq/result/RedHatResult.php index 3d9db2c..5c4d8ec 100644 --- a/qq/result/RedHatResult.php +++ b/qq/result/RedHatResult.php @@ -10,93 +10,93 @@ namespace wchat\qq\result; class RedHatResult { - public mixed $result; - public mixed $res_info; + public mixed $result; + public mixed $res_info; - public mixed $listid; - public mixed $state; - public mixed $total_num; - public mixed $recv_num; - public mixed $total_amount; - public mixed $recv_amount; - public mixed $recv_details; - public mixed $uin; + public mixed $listid; + public mixed $state; + public mixed $total_num; + public mixed $recv_num; + public mixed $total_amount; + public mixed $recv_amount; + public mixed $recv_details; + public mixed $uin; - const RED_HAT_STATUS_PAID = 1; - const RED_HAT_STATUS_SNATCHED = 2; - const RED_HAT_STATUS_EXPIRED = 3; - const RED_HAT_STATUS_REFUNDED = 4; + const RED_HAT_STATUS_PAID = 1; + const RED_HAT_STATUS_SNATCHED = 2; + const RED_HAT_STATUS_EXPIRED = 3; + const RED_HAT_STATUS_REFUNDED = 4; - /** - * RedHatResult constructor. - * @param array $array - */ - public function __construct(array $array) - { - $this->init($array); - } + /** + * RedHatResult constructor. + * @param array $array + */ + public function __construct(array $array) + { + $this->init($array); + } - /** - * @param $array - * @return void - */ - private function init($array): void - { - foreach ($array as $key => $value) { - if (!property_exists($this, $key)) { - continue; - } - $this->{$key} = $value; - } - } + /** + * @param array $array + * @return void + */ + private function init(array $array): void + { + foreach ($array as $key => $value) { + if (!property_exists($this, $key)) { + continue; + } + $this->{$key} = $value; + } + } - /** - * @param $field - * @return mixed - */ - public function get($field): mixed - { - return $this->$field; - } + /** + * @param string $field + * @return mixed + */ + public function get(string $field): mixed + { + return $this->$field; + } - /** - * @return bool - * 是否已完成支付 - */ - public function isPaid(): bool - { - return $this->state == self::RED_HAT_STATUS_PAID; - } + /** + * @return bool + * 是否已完成支付 + */ + public function isPaid(): bool + { + return $this->state == self::RED_HAT_STATUS_PAID; + } - /** - * @return bool - * 是否已抢完 - */ - public function isSnatched(): bool - { - return $this->state == self::RED_HAT_STATUS_SNATCHED; - } + /** + * @return bool + * 是否已抢完 + */ + public function isSnatched(): bool + { + return $this->state == self::RED_HAT_STATUS_SNATCHED; + } - /** - * @return bool - */ - public function isExpired(): bool - { - return $this->state == self::RED_HAT_STATUS_EXPIRED; - } + /** + * @return bool + */ + public function isExpired(): bool + { + return $this->state == self::RED_HAT_STATUS_EXPIRED; + } - /** - * @return bool - */ - public function isRefunded(): bool - { - return $this->state == self::RED_HAT_STATUS_REFUNDED; - } + /** + * @return bool + */ + public function isRefunded(): bool + { + return $this->state == self::RED_HAT_STATUS_REFUNDED; + } }