This commit is contained in:
xl
2023-11-14 14:10:36 +08:00
parent f263014948
commit 70222819b9
13 changed files with 133 additions and 129 deletions
+17 -20
View File
@@ -15,10 +15,10 @@ class Account extends SmallProgram
{
/**
* @param $code
* @param string $code
* @return Result
*/
public function login($code): Result
public function login(string $code): Result
{
$param['appid'] = $this->payConfig->appId;
$param['secret'] = $this->payConfig->appSecret;
@@ -29,10 +29,10 @@ class Account extends SmallProgram
}
/**
* @param $code
* @param string $code
* @return Result
*/
public function AppLogin($code): Result
public function AppLogin(string $code): Result
{
$param['appid'] = $this->payConfig->pay->wx->appId;
$param['secret'] = $this->payConfig->pay->wx->appSecret;
@@ -43,11 +43,10 @@ class Account extends SmallProgram
}
/**
* @param $openid
* @param string $openid
* @return Result
* @throws Exception
*/
public function getPublicUserInfo($openid): Result
public function getPublicUserInfo(string $openid): Result
{
$query = [
'access_token' => $this->payConfig->getAccessToken(),
@@ -58,11 +57,10 @@ class Account extends SmallProgram
}
/**
* @param $openid
* @param string $openid
* @return Result
* @throws Exception
*/
public function getAppUserInfo($openid): Result
public function getAppUserInfo(string $openid): Result
{
$query = [
'access_token' => $this->payConfig->getAccessToken(),
@@ -73,12 +71,11 @@ class Account extends SmallProgram
/**
* @param $path
* @param $width
* @param string $path
* @param int $width
* @return array|mixed|Result
* @throws Exception
*/
public function createwxaqrcode($path, $width): mixed
public function createwxaqrcode(string $path, int $width): mixed
{
$url = 'cgi-bin/wxaapp/createwxaqrcode?access_token=';
$sendBody['path'] = $path;
@@ -89,14 +86,14 @@ class Account extends SmallProgram
/**
* @param $path
* @param $width
* @param string $path
* @param int $width
* @param bool $is_hyaline
* @param bool $auto_color
* @param string $line_color
* @return Result
*/
public function getwxacode($path, $width, bool $is_hyaline = false, bool $auto_color = false, string $line_color = ''): Result
public function getwxacode(string $path, int $width, bool $is_hyaline = false, bool $auto_color = false, string $line_color = ''): Result
{
$sendBody['path'] = $path;
$sendBody['width'] = $width;
@@ -112,14 +109,14 @@ class Account extends SmallProgram
/**
* @param $path
* @param $width
* @param string $path
* @param int $width
* @param bool $is_hyaline
* @param bool $auto_color
* @param string $line_color
* @return Result
*/
public function getwxacodeunlimit($path, $width, bool $is_hyaline = false, bool $auto_color = false, string $line_color = ''): Result
public function getwxacodeunlimit(string $path, int $width, bool $is_hyaline = false, bool $auto_color = false, string $line_color = ''): Result
{
$sendBody['path'] = $path;
$sendBody['width'] = $width;
+2 -2
View File
@@ -115,10 +115,10 @@ class ContentAsyncCheck
}
/**
* @param $params
* @param array $params
* @return $this
*/
private function init($params): static
private function init(array $params): static
{
foreach ($params as $item => $param) {
$this->{'_' . $item} = $param;
+40 -40
View File
@@ -19,19 +19,19 @@ class Message extends SmallProgram
/**
* @param $openid
* @param string $openid
*/
public function setOpenid($openid)
public function setOpenid(string $openid)
{
$this->msgData['touser'] = $openid;
}
/**
* @param $content
* @param string $content
* @return Result
* @throws Exception
*/
public function sendTextNews($content): Result
public function sendTextNews(string $content): Result
{
$this->msgData['msgtype'] = 'text';
$this->msgData['text'] = ['content' => $content];
@@ -40,11 +40,11 @@ class Message extends SmallProgram
}
/**
* @param $media_id
* @param string $media_id
* @return Result
* @throws Exception
*/
public function sendImageNews($media_id): Result
public function sendImageNews(string $media_id): Result
{
$this->msgData['msgtype'] = 'image';
$this->msgData['image'] = ['media_id' => $media_id];
@@ -54,11 +54,11 @@ class Message extends SmallProgram
/**
* @param $media_id
* @param string $media_id
* @return Result
* @throws Exception
*/
public function sendVoiceNews($media_id): Result
public function sendVoiceNews(string $media_id): Result
{
$this->msgData['msgtype'] = 'voice';
$this->msgData['voice'] = ['media_id' => $media_id];
@@ -67,11 +67,11 @@ class Message extends SmallProgram
}
/**
* @param $media_id
* @param string $media_id
* @return Result
* @throws Exception
*/
public function sendMpNewsNews($media_id): Result
public function sendMpNewsNews(string $media_id): Result
{
$this->msgData['msgtype'] = 'mpnews';
$this->msgData['mpnews'] = ['media_id' => $media_id];
@@ -81,14 +81,14 @@ class Message extends SmallProgram
/**
* @param $title
* @param $description
* @param $url
* @param $picurl
* @param string $title
* @param string $description
* @param string $url
* @param string $picurl
* @return Result
* @throws Exception
*/
public function sendNewsNews($title, $description, $url, $picurl): Result
public function sendNewsNews(string $title, string $description, string $url, string $picurl): Result
{
$this->msgData['msgtype'] = 'news';
$this->msgData['news'] = [
@@ -106,11 +106,11 @@ class Message extends SmallProgram
/**
* @param $title
* @param string $title
* @return Result
* @throws Exception
*/
public function sendCardNews($title): Result
public function sendCardNews(string $title): Result
{
$this->msgData['msgtype'] = 'wxcard';
$this->msgData['wxcard'] = ['card_id' => $title];
@@ -120,14 +120,14 @@ class Message extends SmallProgram
/**
* @param $media_id
* @param $thumb_media_id
* @param $title
* @param $description
* @param string $media_id
* @param string $thumb_media_id
* @param string $title
* @param string $description
* @return Result
* @throws Exception
*/
public function sendVideoNews($media_id, $thumb_media_id, $title, $description): Result
public function sendVideoNews(string $media_id, string $thumb_media_id, string $title, string $description): Result
{
$this->msgData['msgtype'] = 'video';
$this->msgData['video'] = [
@@ -143,15 +143,15 @@ class Message extends SmallProgram
/**
* @param $musicurl
* @param $hqmusicurl
* @param $thumb_media_id
* @param $title
* @param $description
* @param string $musicurl
* @param string $hqmusicurl
* @param string $thumb_media_id
* @param string $title
* @param string $description
* @return Result
* @throws Exception
*/
public function sendMusicNews($musicurl, $hqmusicurl, $thumb_media_id, $title, $description): Result
public function sendMusicNews(string $musicurl, string $hqmusicurl, string $thumb_media_id, string $title, string $description): Result
{
$this->msgData['msgtype'] = 'music';
$this->msgData['music'] = [
@@ -166,13 +166,13 @@ class Message extends SmallProgram
/**
* @param $head_content
* @param $tail_content
* @param string $head_content
* @param string $tail_content
* @param array $menus
* @return Result
* @throws Exception
*/
public function sendMenuNews($head_content, $tail_content, array $menus = []): Result
public function sendMenuNews(string $head_content, string $tail_content, array $menus = []): Result
{
$this->msgData['msgtype'] = 'msgmenu';
$this->msgData['msgmenu'] = [
@@ -191,11 +191,11 @@ class Message extends SmallProgram
private int $index = 0;
/**
* @param $id
* @param $menuName
* @param string $id
* @param string $menuName
* @return $this
*/
public function addNewsMenu($id, $menuName): static
public function addNewsMenu(string $id, string $menuName): static
{
$lists['id'] = $id;
$lists['content'] = $menuName;
@@ -205,14 +205,14 @@ class Message extends SmallProgram
}
/**
* @param $title
* @param $appid
* @param $pagepath
* @param $thumb_media_id
* @param string $title
* @param string $appid
* @param string $pagepath
* @param string $thumb_media_id
* @return Result
* @throws Exception
*/
public function sendMiniprogrampageNews($title, $appid, $pagepath, $thumb_media_id): Result
public function sendMiniprogrampageNews(string $title, string $appid, string $pagepath, string $thumb_media_id): Result
{
$this->msgData['msgtype'] = 'msgmenu';
$this->msgData['miniprogrampage'] = [
@@ -270,7 +270,7 @@ class Message extends SmallProgram
* @return Result
* @throws Exception
*/
private function sendKefuMsg()
private function sendKefuMsg(): Result
{
$url = '/cgi-bin/message/custom/send?access_token=' . $this->payConfig->getAccessToken();
return $this->post('api.weixin.qq.com', $url, $this->msgData);
+2 -2
View File
@@ -76,7 +76,7 @@ class Notify extends SmallProgram
* @param $value
* @return void
*/
public function __set(string $name, $value): void
public function __set(string $name, mixed $value): void
{
if (property_exists($this, $name)) {
$this->$name = $value;
@@ -94,7 +94,7 @@ class Notify extends SmallProgram
unset($params['sign']);
$signType = $this->payConfig->getSignType();
$privateKey = $this->payConfig->getKey();
$privateKey = $this->payConfig->pay->wx->secret;
$nowSign = Help::sign($params, $privateKey, $signType);
if ($sign === $nowSign) {
return true;
+18 -18
View File
@@ -33,46 +33,46 @@ class PublicTemplate extends SmallProgram
}
/**
* @param $templateId
* @param string $templateId
*/
public function setTemplateId($templateId)
public function setTemplateId(string $templateId)
{
$this->templateId = $templateId;
}
/**
* @param $openId
* @param string $openId
*/
public function setOpenId($openId)
public function setOpenId(string $openId)
{
$this->openId = $openId;
}
/**
* @param $defaultUrl
* @param string $defaultUrl
*/
public function setDefaultUrl($defaultUrl)
public function setDefaultUrl(string $defaultUrl)
{
$this->defaultUrl = $defaultUrl;
}
/**
* @param $name
* @param $context
* @param string $name
* @param string $context
* @param string $color
*/
public function replaceKeyword($name, $context, string $color = '')
public function replaceKeyword(string $name, string $context, string $color = '')
{
$this->keywords[$name] = ['value' => $context, 'color' => $color];
}
/**
* @param $name
* @param $context
* @param string $name
* @param string $context
* @param null $color
*/
public function addKeyword($name, $context, $color = null)
public function addKeyword(string $name, string $context, $color = null)
{
if (empty($color)) {
$color = '#000';
@@ -84,11 +84,11 @@ class PublicTemplate extends SmallProgram
}
/**
* @param $context
* @param string $context
* @param string $color
* @return void
*/
public function setFirst($context, string $color = '#f00'): void
public function setFirst(string $context, string $color = '#f00'): void
{
$this->first = [
'value' => $context,
@@ -97,11 +97,11 @@ class PublicTemplate extends SmallProgram
}
/**
* @param $context
* @param string $context
* @param string $color
* @return void
*/
public function setRemark($context, string $color = '#000'): void
public function setRemark(string $context, string $color = '#000'): void
{
$this->remark = [
'value' => $context,
@@ -110,11 +110,11 @@ class PublicTemplate extends SmallProgram
}
/**
* @param $appid
* @param string $appid
* @param string $pagepath
* @return void
*/
public function setMiniprogram($appid, string $pagepath): void
public function setMiniprogram(string $appid, string $pagepath): void
{
$this->miniprogram = [
'appid' => $appid,
+4 -4
View File
@@ -55,20 +55,20 @@ class SecCheck extends SmallProgram
/**
* @param $params
* @param array $params
* @return ContentAsyncCheck|null
*/
public function readByEvent($params): ?ContentAsyncCheck
public function readByEvent(array $params): ?ContentAsyncCheck
{
return ContentAsyncCheck::instance($params);
}
/**
* @param $content
* @param string $content
* @return Result
*/
public function text($content): Result
public function text(string $content): Result
{
if (empty($content)) {
return $this->sendError('文件不存在', 404);
+2 -2
View File
@@ -14,14 +14,14 @@ class WxV3AppPayment extends SmallProgram
/**
* @param $orderNo
* @param string $orderNo
* @param int $total
* @param string|null $openId
* @param string $payer_client_ip
* @return array
* @throws Exception
*/
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
{
$body = $this->getInitCore($orderNo, $total);
+2 -2
View File
@@ -15,7 +15,7 @@ class WxV3NativePayment extends SmallProgram
/**
* @param $orderNo
* @param string $orderNo
* @param int $total
* @param string|null $openId
* @param string $payer_client_ip
@@ -23,7 +23,7 @@ class WxV3NativePayment extends SmallProgram
* @throws Exception
*/
#[ArrayShape(['code_url' => "string"])]
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
{
$body = $this->getInitCore($orderNo, $total);
+2 -2
View File
@@ -14,14 +14,14 @@ class WxV3Payment extends SmallProgram
/**
* @param $orderNo
* @param string $orderNo
* @param int $total
* @param string|null $openId
* @param string $payer_client_ip
* @return array
* @throws Exception
*/
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
{
$body = $this->getInitCore($orderNo, $total);
$body['payer'] = ['openid' => $openId];
+8 -8
View File
@@ -93,10 +93,10 @@ class WxV3PaymentNotify extends SmallProgram
/**
* @param string $message
* @param string $signature
* @param $publicKey
* @param OpenSSLAsymmetricKey $publicKey
* @return bool
*/
protected function notifyVerify(string $message, string $signature, $publicKey): bool
protected function notifyVerify(string $message, string $signature, OpenSSLAsymmetricKey $publicKey): bool
{
if (($result = openssl_verify($message, base64_decode($signature), $publicKey, OPENSSL_ALGO_SHA256)) === false) {
throw new \UnexpectedValueException('Verified the input $message failed, please checking your $publicKey whether or nor correct.');
@@ -106,11 +106,11 @@ class WxV3PaymentNotify extends SmallProgram
/**
* @param $thing
* @param string $thing
* @param string $type
* @return OpenSSLAsymmetricKey
*/
protected function rsaFrom($thing, string $type = KEY_TYPE_PRIVATE): OpenSSLAsymmetricKey
protected function rsaFrom(string $thing, string $type = KEY_TYPE_PRIVATE): OpenSSLAsymmetricKey
{
$pkey = (($isPublic = $type === KEY_TYPE_PUBLIC) ? openssl_pkey_get_public(file_get_contents($thing)) : openssl_pkey_get_private(file_get_contents($thing)));
if (false === $pkey) {
@@ -120,12 +120,12 @@ class WxV3PaymentNotify extends SmallProgram
}
/**
* @param $ciphertext
* @param $nonce
* @param $associated_data
* @param string $ciphertext
* @param string $nonce
* @param string $associated_data
* @return bool
*/
public function decode($ciphertext, $nonce, $associated_data): bool
public function decode(string $ciphertext, string $nonce, string $associated_data): bool
{
$data = $this->decrypt($ciphertext, $this->payConfig->pay->wx->secret, $nonce, $associated_data);
$this->notifyModel = new NotifyModel();
+8 -8
View File
@@ -21,11 +21,11 @@ trait WxV3PaymentTait
{
/**
* @param $orderNo
* @param $total
* @param string $orderNo
* @param int $total
* @return array
*/
public function getInitCore($orderNo, $total): array
public function getInitCore(string $orderNo, int $total): array
{
$payConfig = $this->getPayConfig();
if ($payConfig->typeIsApp()) {
@@ -87,10 +87,10 @@ trait WxV3PaymentTait
/**
* @param $body
* @param string $body
* @return string
*/
public function openssl_signature($body): string
public function openssl_signature(string $body): string
{
$payConfig = $this->getPayConfig();
@@ -102,11 +102,11 @@ trait WxV3PaymentTait
/**
* @param $json
* @param $body
* @param array $json
* @param array $body
* @return array
*/
private function createResponse($json, $body): array
private function createResponse(array $json, array $body): array
{
$responseArray['appId'] = $body['appid'];
$responseArray['timeStamp'] = (string)time();
+10 -3
View File
@@ -15,14 +15,14 @@ class WxV3Withdrawal extends SmallProgram
/**
* @param $orderNo
* @param string $orderNo
* @param string $batch_name
* @param string $batch_remark
* @param TransferDetail[] $details
* @return array
* @throws Exception
*/
public function payment($orderNo, string $batch_name, string $batch_remark, array $details): array
public function payment(string $orderNo, string $batch_name, string $batch_remark, array $details): array
{
$body = $this->create($orderNo, $batch_name, $batch_remark, $details);
@@ -41,8 +41,15 @@ class WxV3Withdrawal extends SmallProgram
}
/**
* @param string $orderNo
* @param string $batch_name
* @param string $batch_remark
* @param array $details
* @return array[]
*/
#[ArrayShape(['transfer_detail_list' => "array", 'total_amount' => "int", 'total_num' => "int", 'batch_remark' => "string", 'batch_name' => "string", 'out_batch_no' => ""])]
private function create($orderNo, string $batch_name, string $batch_remark, array $details): array
private function create(string $orderNo, string $batch_name, string $batch_remark, array $details): array
{
$total = 0;
$body = ['transfer_detail_list' => []];
+2 -2
View File
@@ -11,12 +11,12 @@ class WxFactory
/**
* @param $class
* @param string $class
* @param AppConfig $config
* @return object|null
* @throws ReflectionException
*/
public static function get($class, AppConfig $config): ?object
public static function get(string $class, AppConfig $config): ?object
{
$container = Container::instance();
$object = $container->get($class);