Skip to content

Commit cdf868d

Browse files
committed
style(header): 统一核心契约缓存和测试文件格式
- 按 PHP-CS-Fixer 规则补齐核心契约、异常、缓存和 XML 工具文件头。 - 规范导入、PHPDoc 类型顺序与注释格式,保持项目头信息不丢失。 - 同步整理缓存键、缓存实现、XML 编解码相关测试和 bootstrap 格式。
1 parent 09f64b4 commit cdf868d

16 files changed

Lines changed: 80 additions & 49 deletions

src/Contract/ConfigInterface.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* 平台配置契约。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Contract;

src/Contract/StoreCacheInterface.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* SDK 运行态缓存契约。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Contract;

src/Contract/StoreTokenInterface.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* 微信服务平台授权方 Token 存储契约。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Contract;

src/Exception/ApiException.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* 平台接口请求异常。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Exception;

src/Exception/SignatureException.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* 签名与验签异常。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Exception;

src/Exception/WechatException.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* SDK 基础异常。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Exception;
1012

11-
use RuntimeException;
12-
use Throwable;
13-
1413
/**
1514
* SDK 基础异常。
1615
*
1716
* 通过 context() 暴露平台响应、验签明细等上下文,便于业务侧记录日志和排查问题。
1817
*/
19-
class WechatException extends RuntimeException
18+
class WechatException extends \RuntimeException
2019
{
2120
/**
2221
* 创建 SDK 异常并保存可选上下文。
@@ -26,7 +25,7 @@ class WechatException extends RuntimeException
2625
public function __construct(
2726
string $message,
2827
int $code = 0,
29-
?Throwable $previous = null,
28+
?\Throwable $previous = null,
3029
private readonly array $context = []
3130
) {
3231
parent::__construct($message, $code, $previous);

src/Support/CacheKey.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* 缓存键生成工具。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Support;
@@ -18,9 +20,9 @@ final class CacheKey
1820
/**
1921
* 组合缓存完整键。
2022
*
21-
* @param string $prefix 根 Client 通用命名段,不得为空,用于区分部署、租户或应用
23+
* @param string $prefix 根 Client 通用命名段,不得为空,用于区分部署、租户或应用
2224
* @param string $channel 通道段,如 `wechat.platform`,必须与 Client 通道标识一致。
23-
* @param string $logicalKey 业务逻辑键,如 TokenCacheKey 生成的 access_token 键
25+
* @param string $logicalKey 业务逻辑键,如 TokenCacheKey 生成的 access_token 键
2426
*/
2527
public static function compose(string $prefix, string $channel, string $logicalKey): string
2628
{

src/Support/FileCacheStore.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* 本地文件缓存实现。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Support;
@@ -60,7 +62,7 @@ public function get(string $key, mixed $default = null): mixed
6062
return $default;
6163
}
6264

63-
/** @var array{expires_at?:int,value?:mixed}|null $payload */
65+
/** @var null|array{expires_at?:int,value?:mixed} $payload */
6466
$payload = json_decode($raw, true);
6567
if (!is_array($payload) || !array_key_exists('expires_at', $payload) || !array_key_exists('value', $payload)) {
6668
return $default;

src/Support/NullCacheStore.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* 空缓存实现。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Support;

src/Support/PsrSimpleCacheStore.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

33
declare(strict_types=1);
4-
54
/**
6-
* PSR-16 缓存适配器。
5+
* This file is part of HyperfAdmin.
6+
*
7+
* @Link https://thinkadmin.top
8+
* @Author Anyon<zoujingli@qq.com>
79
*/
810

911
namespace We\Support;

0 commit comments

Comments
 (0)