Skip to content

Commit

Permalink
修复一些注解问题 (#628)
Browse files Browse the repository at this point in the history
* 修复一些注解问题

* 修正文档
  • Loading branch information
Yurunsoft authored Nov 2, 2023
1 parent 186defc commit d6efa31
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions doc/components/udpServer/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
```

路由匹配成功,就会执行这个动作。
Expand Down
5 changes: 3 additions & 2 deletions src/Bean/Annotation/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Validate/Annotation/Scene.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setJson(array $json): self
}

/**
* @Column(type="json", arrayWrap=true)
* @Column(type="json")
*/
protected array $jsonArray = [];

Expand Down

0 comments on commit d6efa31

Please sign in to comment.