Skip to content

Commit 3512f78

Browse files
committed
remove invalid property
1 parent 4e959fc commit 3512f78

File tree

2 files changed

+20
-54
lines changed

2 files changed

+20
-54
lines changed

src/AbstractApplication.php

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ abstract class AbstractApplication implements ApplicationInterface
5656
'profile' => false,
5757
'version' => '0.5.1',
5858
'publishAt' => '2017.03.24',
59-
'updateAt' => '2017.03.24',
59+
'updateAt' => '2019.01.01',
6060
'rootPath' => '',
6161
'hideRootPath' => true,
6262

6363
// 'timeZone' => 'Asia/Shanghai',
64-
// 'env' => 'pdt', // dev test pdt
64+
// 'env' => 'prod', // dev test prod
6565
// 'charset' => 'UTF-8',
6666

6767
'logoText' => '',
@@ -74,15 +74,12 @@ abstract class AbstractApplication implements ApplicationInterface
7474
/** @var string Command delimiter. e.g dev:serve */
7575
public $delimiter = ':'; // '/' ':'
7676

77-
/** @var string Current command name */
78-
private $commandName;
79-
80-
/** @var array Some metadata for command */
77+
/**
78+
* @var array Some metadata for command
79+
* - description
80+
*/
8181
private $commandsMeta = [];
8282

83-
/** @var array Some message for command */
84-
private $commandMessages = [];
85-
8683
/** @var array Save command aliases */
8784
private $commandAliases = [];
8885

@@ -126,8 +123,6 @@ protected function init()
126123
'endMemory' => 0,
127124
];
128125

129-
$this->commandName = $this->input->getCommand();
130-
131126
$this->registerErrorHandle();
132127
}
133128

@@ -504,30 +499,6 @@ public function showCommandList($quit = true)
504499
$quit && $this->stop();
505500
}
506501

507-
/**
508-
* @param string $name
509-
* @param string $default
510-
* @return string|null
511-
*/
512-
public function getCommandMessage(string $name, $default = null)
513-
{
514-
return $this->commandMessages[$name] ?? $default;
515-
}
516-
517-
/**
518-
* @param string $name The command name
519-
* @param string $message
520-
* @return $this
521-
*/
522-
public function addCommandMessage($name, $message): self
523-
{
524-
if ($name && $message) {
525-
$this->commandMessages[$name] = $message;
526-
}
527-
528-
return $this;
529-
}
530-
531502
/**
532503
* @param string $name
533504
* @param string|array $aliases
@@ -834,7 +805,9 @@ public function getCommandMeta(string $command): array
834805
*/
835806
public function setCommandMetaValue(string $command, string $key, $value)
836807
{
837-
$this->commandsMeta[$command][$key] = $value;
808+
if ($value !== null) {
809+
$this->commandsMeta[$command][$key] = $value;
810+
}
838811
}
839812

840813
/**

src/Application.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ class Application extends AbstractApplication
2121
****************************************************************************/
2222

2323
/**
24-
* Register a app group command(by controller)
25-
* @param string $name The controller name
26-
* @param string|Controller $class The controller class
27-
* @param null|array|string $option
28-
* @return static
29-
* @throws \InvalidArgumentException
24+
* {@inheritdoc}
3025
*/
3126
public function controller(string $name, $class = null, $option = null)
3227
{
@@ -69,10 +64,11 @@ public function controller(string $name, $class = null, $option = null)
6964
// has option information
7065
if ($option) {
7166
if (\is_string($option)) {
72-
$this->addCommandMessage($name, $option);
67+
$this->setCommandMetaValue($name, 'description', $option);
7368
} elseif (\is_array($option)) {
7469
$this->addCommandAliases($name, $option['aliases'] ?? null);
75-
$this->addCommandMessage($name, $option['description'] ?? null);
70+
unset($option['aliases']);
71+
$this->setCommandMeta($name, $option);
7672
}
7773
}
7874

@@ -99,12 +95,7 @@ public function controllers(array $controllers)
9995
}
10096

10197
/**
102-
* Register a app independent console command
103-
* @param string|Command $name
104-
* @param string|\Closure|Command $handler
105-
* @param null|array|string $option
106-
* @return $this|mixed
107-
* @throws \InvalidArgumentException
98+
* {@inheritdoc}
10899
*/
109100
public function command(string $name, $handler = null, $option = null)
110101
{
@@ -139,17 +130,18 @@ public function command(string $name, $handler = null, $option = null)
139130
return $this;
140131
}
141132

142-
// allow define aliases in Command class by Command::aliases()
143-
if ($aliases = $handler::aliases()) {
144-
$option['aliases'] = isset($option['aliases']) ? \array_merge($option['aliases'], $aliases) : $aliases;
145-
}
146133
} elseif (!\is_object($handler) || !\method_exists($handler, '__invoke')) {
147134
Helper::throwInvalidArgument(
148135
'The console command handler must is an subclass of %s OR a Closure OR a object have method __invoke()',
149136
Command::class
150137
);
151138
}
152139

140+
// allow define aliases in Command class by Command::aliases()
141+
if ($aliases = $handler::aliases()) {
142+
$option['aliases'] = isset($option['aliases']) ? \array_merge($option['aliases'], $aliases) : $aliases;
143+
}
144+
153145
// is an class name string
154146
$this->commands[$name] = $handler;
155147

@@ -159,6 +151,7 @@ public function command(string $name, $handler = null, $option = null)
159151
$this->setCommandMetaValue($name, 'description', $option);
160152
} elseif (\is_array($option)) {
161153
$this->addCommandAliases($name, $option['aliases'] ?? null);
154+
unset($option['aliases']);
162155
$this->setCommandMeta($name, $option);
163156
}
164157
}

0 commit comments

Comments
 (0)