Skip to content

Commit 106d72b

Browse files
committed
chore: update readme and some method comments
1 parent 28bd7a2 commit 106d72b

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
- 功能全面的命令行的选项、参数解析
2525
- 命名参数,数组参数
2626
- 选项绑定 短选项 `-s`,长选项 `--long`
27-
- 支持定义数据类型(`bool,int,string,array`),解析后会自动格式化输入值
27+
- **NEW** v4 支持定义数据类型(`bool,int,string,array`),解析后会自动格式化输入值
2828
- 命令方法注释自动解析为帮助信息
2929
- 默认提取 `@usage` `@arguments` `@options` `@example` 等信息
3030
- **NEW** v4 版本支持从注释定义选项参数的数据类型

src/Command.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ abstract class Command extends AbstractHandler implements CommandInterface
3333
{
3434
public const METHOD = 'execute';
3535

36+
/**
37+
* @var Controller
38+
*/
39+
protected $group;
40+
3641
/**
3742
* @var Command
3843
*/
@@ -130,4 +135,24 @@ public function getRealCName(): string
130135
{
131136
return self::getName();
132137
}
138+
139+
/**
140+
* Get the group
141+
*
142+
* @return Controller
143+
*/
144+
public function getGroup()
145+
{
146+
return $this->group;
147+
}
148+
149+
/**
150+
* Set the value of group
151+
*
152+
* @param Controller $group
153+
*/
154+
public function setGroup(Controller $group): void
155+
{
156+
$this->group = $group;
157+
}
133158
}

src/Contract/RouterInterface.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ interface RouterInterface
3232
*
3333
* @param string $name The controller name
3434
* @param string|ControllerInterface $class The controller class
35-
* @param array $options array:
36-
* - aliases The command aliases
37-
* - description The description message
35+
* @param array{aliases: array, desc: string} $options The options
36+
* - aliases The command aliases
37+
* - desc The description message
3838
*
3939
* @return static
4040
* @throws InvalidArgumentException
@@ -46,10 +46,9 @@ public function addGroup(string $name, $class = null, array $options = []): self
4646
*
4747
* @param string|CommandInterface $name
4848
* @param string|Closure|CommandInterface $handler
49-
* @param array $options
50-
* array:
51-
* - aliases The command aliases
52-
* - description The description message
49+
* @param array{aliases: array, desc: string} $options The options
50+
* - aliases The command aliases
51+
* - desc The description message
5352
*
5453
* @return static
5554
* @throws InvalidArgumentException

src/Controller.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ abstract class Controller extends AbstractHandler implements ControllerInterface
7979
*/
8080
private $action = '';
8181

82-
/**
83-
* The action method name on the controller.
84-
*
85-
* @var string
86-
*/
87-
private $actionMethod = '';
88-
8982
/**
9083
* The input group name.
9184
*
@@ -105,6 +98,13 @@ abstract class Controller extends AbstractHandler implements ControllerInterface
10598
*/
10699
private $defaultAction = '';
107100

101+
/**
102+
* The action method name on the controller.
103+
*
104+
* @var string
105+
*/
106+
private $actionMethod = '';
107+
108108
/**
109109
* @var string
110110
*/
@@ -213,7 +213,7 @@ protected function disabledCommands(): array
213213
*/
214214
protected function onNotFound(string $action, array $args): bool
215215
{
216-
// you can add custom logic on sub-command not found.
216+
// TIP: you can add custom logic on sub-command not found.
217217
return false;
218218
}
219219

0 commit comments

Comments
 (0)