From d6efa31e3d525cc83ece74eed16eb0acf870d356 Mon Sep 17 00:00:00 2001 From: Yurun Date: Thu, 2 Nov 2023 17:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=E9=97=AE=E9=A2=98=20(#628)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复一些注解问题 * 修正文档 --- doc/components/udpServer/controller.md | 8 ++++---- src/Bean/Annotation/Base.php | 5 +++-- src/Validate/Annotation/Scene.php | 2 +- .../Model/TestRedisHashObjectColumnTypeModel.php | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/components/udpServer/controller.md b/doc/components/udpServer/controller.md index 91e687294a..1fc1e933d9 100644 --- a/doc/components/udpServer/controller.md +++ b/doc/components/udpServer/controller.md @@ -56,18 +56,18 @@ class Test extends \Imi\Controller\UdpController ```php // 解析 $data['action'] === 'login' -@TcpRoute({"action"="login"}) +@UdpRoute({"action"="login"}) // 解析 $data['a']['b']['c'] === 'login' -@TcpRoute({"a.b.c"="login"}) +@UdpRoute({"a.b.c"="login"}) // 解析 $data['a'] == '1' && $data['b'] == '2' -@TcpRoute({"a"="1", "b"="2"}) +@UdpRoute({"a"="1", "b"="2"}) ``` 当然对象也是支持的: ```php // 解析 $data->a->b->c === 'login' -@TcpRoute({"a.b.c"="login"}) +@UdpRoute({"a.b.c"="login"}) ``` 路由匹配成功,就会执行这个动作。 diff --git a/src/Bean/Annotation/Base.php b/src/Bean/Annotation/Base.php index c7e917c2af..1f9ec22c8d 100644 --- a/src/Bean/Annotation/Base.php +++ b/src/Bean/Annotation/Base.php @@ -43,9 +43,10 @@ public function __construct(?array $__data = null, ...$__args) { continue; } - if (isset($__args[$i - 1])) + $key = (int) ($i - 1); + if (\array_key_exists($key, $__args)) { - $data[$name] = $__args[$i - 1]; + $data[$name] = $__args[$key]; } else { diff --git a/src/Validate/Annotation/Scene.php b/src/Validate/Annotation/Scene.php index cdf9b6a6f6..d4eea31a00 100644 --- a/src/Validate/Annotation/Scene.php +++ b/src/Validate/Annotation/Scene.php @@ -17,7 +17,7 @@ * @property string $name 场景名称 * @property array $fields 需要验证的字段名列表 */ -#[\Attribute(\Attribute::TARGET_CLASS)] +#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] class Scene extends Base { public function __construct(?array $__data = null, string $name = '', array $fields = []) diff --git a/tests/unit/Component/Model/TestRedisHashObjectColumnTypeModel.php b/tests/unit/Component/Model/TestRedisHashObjectColumnTypeModel.php index b3c41fabee..7a55d1a64f 100644 --- a/tests/unit/Component/Model/TestRedisHashObjectColumnTypeModel.php +++ b/tests/unit/Component/Model/TestRedisHashObjectColumnTypeModel.php @@ -36,7 +36,7 @@ public function setJson(array $json): self } /** - * @Column(type="json", arrayWrap=true) + * @Column(type="json") */ protected array $jsonArray = [];