Skip to content

Commit 3f63356

Browse files
committed
some class name modify
1 parent b74e8b9 commit 3f63356

File tree

7 files changed

+73
-43
lines changed

7 files changed

+73
-43
lines changed

โ€Žsrc/Base/AbstractApplication.phpโ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,22 @@ public function run($exit = true)
146146
$this->filterSpecialCommand($command);
147147

148148
// call 'onBeforeRun' service, if it is registered.
149-
self::fire(self::ON_BEFORE_RUN, [$this]);
149+
$this->fire(self::ON_BEFORE_RUN, [$this]);
150150
$this->beforeRun();
151151

152152
// do run ...
153153
try {
154154
$returnCode = $this->dispatch($command);
155155
} catch (\Throwable $e) {
156-
self::fire(self::ON_RUN_ERROR, [$e, $this]);
156+
$this->fire(self::ON_RUN_ERROR, [$e, $this]);
157157
$returnCode = $e->getCode() === 0 ? $e->getLine() : $e->getCode();
158158
$this->handleException($e);
159159
}
160160

161161
$this->meta['_stats']['endTime'] = microtime(1);
162162

163163
// call 'onAfterRun' service, if it is registered.
164-
self::fire(self::ON_AFTER_RUN, [$this]);
164+
$this->fire(self::ON_AFTER_RUN, [$this]);
165165
$this->afterRun();
166166

167167
if ($exit) {
@@ -206,7 +206,7 @@ protected function afterRun()
206206
public function stop($code = 0)
207207
{
208208
// call 'onAppStop' service, if it is registered.
209-
self::fire(self::ON_STOP_RUN, [$this]);
209+
$this->fire(self::ON_STOP_RUN, [$this]);
210210

211211
exit((int)$code);
212212
}

โ€Žsrc/IO/Input.phpโ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Inhere\Console\IO;
1010

11-
use Inhere\Console\Utils\CommandLine;
11+
use Inhere\Console\Utils\InputParser;
1212

1313
/**
1414
* Class Input - the input information. by parse global var $argv.
@@ -83,11 +83,11 @@ public function __construct($argv = null, $parsing = true)
8383

8484
$this->pwd = $this->getPwd();
8585
$this->tokens = $argv;
86-
$this->fullScript = implode(' ', $argv);
8786
$this->script = array_shift($argv);
87+
$this->fullScript = implode(' ', $argv);
8888

8989
if ($parsing) {
90-
list($this->args, $this->sOpts, $this->lOpts) = CommandLine::parseByArgv($argv);
90+
list($this->args, $this->sOpts, $this->lOpts) = InputParser::fromArgv($argv);
9191

9292
// collect command. it is first argument.
9393
$this->command = isset($this->args[0]) ? array_shift($this->args) : null;
@@ -101,11 +101,11 @@ public function __toString()
101101
{
102102
$tokens = array_map(function ($token) {
103103
if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
104-
return $match[1] . CommandLine::escapeToken($match[2]);
104+
return $match[1] . InputParser::escapeToken($match[2]);
105105
}
106106

107107
if ($token && $token[0] !== '-') {
108-
return CommandLine::escapeToken($token);
108+
return InputParser::escapeToken($token);
109109
}
110110

111111
return $token;

โ€Žsrc/Traits/SimpleEventTrait.phpโ€Ž

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ trait SimpleEventTrait
4545
* @param callable $handler
4646
* @param bool $once
4747
*/
48-
public static function on($event, callable $handler, $once = false)
48+
public function on(string $event, callable $handler, $once = false)
4949
{
5050
if (self::isSupportedEvent($event)) {
5151
self::$eventHandlers[$event][] = $handler;
@@ -61,9 +61,9 @@ public static function on($event, callable $handler, $once = false)
6161
* @param $event
6262
* @param callable $handler
6363
*/
64-
public static function once($event, callable $handler)
64+
public function once(string $event, callable $handler)
6565
{
66-
self::on($event, $handler, true);
66+
$this->on($event, $handler, true);
6767
}
6868

6969
/**
@@ -72,7 +72,7 @@ public static function once($event, callable $handler)
7272
* @param array $args
7373
* @return bool
7474
*/
75-
public static function fire($event, array $args = [])
75+
public function fire(string $event, array $args = []): bool
7676
{
7777
if (!isset(self::$events[$event])) {
7878
return false;
@@ -88,7 +88,7 @@ public static function fire($event, array $args = [])
8888

8989
// is a once event, remove it
9090
if (self::$events[$event]) {
91-
return self::off($event);
91+
return $this->off($event);
9292
}
9393

9494
return true;
@@ -99,9 +99,9 @@ public static function fire($event, array $args = [])
9999
* @param $event
100100
* @return bool
101101
*/
102-
public static function off($event)
102+
public function off(string $event): bool
103103
{
104-
if (self::hasEvent($event)) {
104+
if ($this->hasEvent($event)) {
105105
unset(self::$events[$event], self::$eventHandlers[$event]);
106106

107107
return true;
@@ -114,7 +114,7 @@ public static function off($event)
114114
* @param $event
115115
* @return bool
116116
*/
117-
public static function hasEvent($event)
117+
public function hasEvent(string $event): bool
118118
{
119119
return isset(self::$events[$event]);
120120
}
@@ -123,9 +123,9 @@ public static function hasEvent($event)
123123
* @param $event
124124
* @return bool
125125
*/
126-
public static function isOnce($event)
126+
public function isOnce(string $event): bool
127127
{
128-
if (self::hasEvent($event)) {
128+
if ($this->hasEvent($event)) {
129129
return self::$events[$event];
130130
}
131131

@@ -134,10 +134,10 @@ public static function isOnce($event)
134134

135135
/**
136136
* check $name is a supported event name
137-
* @param $event
137+
* @param string $event
138138
* @return bool
139139
*/
140-
public static function isSupportedEvent($event)
140+
public static function isSupportedEvent(string $event): bool
141141
{
142142
if (!$event || !preg_match('/[a-zA-z][\w-]+/', $event)) {
143143
return false;
@@ -153,7 +153,7 @@ public static function isSupportedEvent($event)
153153
/**
154154
* @return array
155155
*/
156-
public static function getSupportEvents()
156+
public static function getSupportEvents(): array
157157
{
158158
return self::$supportedEvents;
159159
}
@@ -169,15 +169,15 @@ public static function setSupportEvents(array $supportedEvents)
169169
/**
170170
* @return array
171171
*/
172-
public static function getEvents()
172+
public static function getEvents(): array
173173
{
174174
return self::$events;
175175
}
176176

177177
/**
178178
* @return int
179179
*/
180-
public static function countEvents()
180+
public static function countEvents(): int
181181
{
182182
return \count(self::$events);
183183
}

โ€Žsrc/Utils/Annotation.phpโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*/
1515
final class Annotation
1616
{
17-
/*
18-
* ไปฅไธ‹ไธ‰ไธชๆ–นๆณ•ๆฅ่‡ช yii2 console/Controller.php
17+
/**
18+
* ไปฅไธ‹ไธ‰ไธชๆ–นๆณ•ๆฅ่‡ช yii2 console/Controller.php ๅšไบ†ไธ€ไบ›่ฐƒๆ•ด
1919
*/
2020

2121
/**

โ€Žsrc/Utils/CommandLine.phpโ€Ž renamed to โ€Žsrc/Utils/InputParser.phpโ€Ž

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
namespace Inhere\Console\Utils;
1010

1111
/**
12-
* Class CommandLine - console argument and option parse
12+
* Class InputParser - console argument and option parse
1313
* @package Inhere\Console\Utils
1414
*/
15-
final class CommandLine
15+
final class InputParser
1616
{
1717
/**
1818
* These words will be as a Boolean value
@@ -27,7 +27,7 @@ final class CommandLine
2727
* php cli.php server start name=john city=chengdu -s=test --page=23 -d -rf --debug --task=off -y=false -D -e dev -v vvv
2828
* ```
2929
* ```php
30-
* $result = CommandLineParse::byArgv($_SERVER['argv']);
30+
* $result = InputParser::fromArgv($_SERVER['argv']);
3131
* ```
3232
* Supports args:
3333
* <value>
@@ -44,7 +44,7 @@ final class CommandLine
4444
* @param array $config
4545
* @return array
4646
*/
47-
public static function parseByArgv(array $params, array $config = []): array
47+
public static function fromArgv(array $params, array $config = []): array
4848
{
4949
$config = array_merge([
5050
// List of parameters without values(bool option keys)
@@ -89,7 +89,7 @@ public static function parseByArgv(array $params, array $config = []): array
8989
$nxt = current($params);
9090

9191
// next elem is value. fix: allow empty string ''
92-
if ($val === true && self::nextIsValue($nxt) && !isset($noValues[$opt])) {
92+
if ($val === true && !isset($noValues[$opt]) && self::nextIsValue($nxt)) {
9393
// list(,$val) = each($params);
9494
$val = $nxt;
9595
next($params);
@@ -139,15 +139,15 @@ public static function parseByArgv(array $params, array $config = []): array
139139
return [$args, $sOpts, $lOpts];
140140
}
141141

142-
public static function parseByDefinition(array $tokens, array $allowArray = [], array $noValues = [])
142+
public static function fromDefinition(array $tokens, array $allowArray = [], array $noValues = [])
143143
{
144144

145145
}
146146

147147
/**
148148
* parse custom array params
149149
* ```php
150-
* $result = CommandLine::parseByArray([
150+
* $result = InputParser::fromArray([
151151
* 'arg' => 'val',
152152
* '--lp' => 'val2',
153153
* '--s' => 'val3',
@@ -156,7 +156,7 @@ public static function parseByDefinition(array $tokens, array $allowArray = [],
156156
* @param array $params
157157
* @return array
158158
*/
159-
public static function parseByArray(array $params): array
159+
public static function fromArray(array $params): array
160160
{
161161
$args = $sOpts = $lOpts = [];
162162

@@ -179,12 +179,12 @@ public static function parseByArray(array $params): array
179179

180180
/**
181181
* ```php
182-
* $result = CommandLine::parseByString('foo --bar="foobar"');
182+
* $result = InputParser::fromString('foo --bar="foobar"');
183183
* ```
184184
* @todo ...
185185
* @param string $string
186186
*/
187-
public static function parseByString(string $string)
187+
public static function fromString(string $string)
188188
{
189189

190190
}

โ€Žsrc/Utils/FontSymbol.phpโ€Ž renamed to โ€Žsrc/Utils/Symbol/Char.phpโ€Ž

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,32 @@
1313
* - ๅญ—ไฝ“็ฌฆๅท
1414
* @package Inhere\Console\Utils
1515
*/
16-
class FontSymbol
16+
final class Char
1717
{
1818
const OK = 'โœ”';
1919
const NO = 'โœ˜';
2020
const PEN = 'โœŽ';
21+
2122
const HEART = 'โค';
23+
const SMILE = 'โ˜บ';
24+
25+
const FLOWER = 'โœฟ';
26+
const MUSIC = 'โ™ฌ';
2227

2328
const UP = '๎€”';
2429
const DOWN = '๎€•';
2530
const LEFT = '๎€’';
2631
const RIGHT = '๎€“';
32+
const SEARCH = '๎€€';
2733

2834
const MALE = 'โ™‚';
2935
const FEMALE = 'โ™€';
3036

37+
const SUN = 'โ˜€';
38+
const STAR = 'โ˜…';
39+
const SNOW = 'โˆ';
40+
const CLOUD = 'โ˜';
41+
3142
/**
3243
* @return array
3344
*/

โ€Žsrc/Utils/EmojiSymbol.phpโ€Ž renamed to โ€Žsrc/Utils/Symbol/Emoji.phpโ€Ž

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,50 @@
99
namespace Inhere\Console\Utils;
1010

1111
/**
12-
* Class EmojiSymbol
12+
* Class Emoji
1313
* @package Inhere\Console\Utils
1414
*/
15-
class EmojiSymbol
15+
final class Emoji
1616
{
1717
const KEY = '๐Ÿ”‘';
1818
const BOX = '๐Ÿ“ฆ';
1919
const GIFT = '๐ŸŽ';
2020
const CLOCK = 'โฐ';
2121
const FLAG = '๐Ÿšฉ';
22+
const TOOL = '๐Ÿ”ง';
23+
const GUN = '๐Ÿ”ซ';
2224

2325
const DOC = '๐Ÿ“„';
2426
const DIR = '๐Ÿ“‚';
2527
const BOOK = '๐Ÿ“”';
28+
const RECYCLE = 'โ™ป';
2629

27-
const TOOL = '๐Ÿ”ง';
28-
const GUN = '๐Ÿ”ซ';
30+
const EDIT = 'โœ';
31+
const SMILE = '๐Ÿ˜Š';
32+
const LAUGH = '๐Ÿ˜†';
33+
const LIKE = '๐Ÿ˜';
34+
const ANGER = '๐Ÿ˜ก';
35+
const HAPPY = '๐Ÿ˜€';
36+
const DOZE = '๐Ÿ˜ด';
37+
38+
const OK = '๐Ÿ‘Œ';
39+
const YES = 'โœŒ';
40+
const NO = 'โœ‹';
41+
const PRAISE = '๐Ÿ‘';
42+
const TREAD = '๐Ÿ‘Ž';
43+
const STEP = '๐Ÿพ';
2944

30-
const UP = '๐Ÿ‘';
31-
const DOWN = '๐Ÿ‘Ž';
45+
const UP = '๐Ÿ‘†';
46+
const DOWN = '๐Ÿ‘‡';
47+
const LEFT = '๐Ÿ‘ˆ';
48+
const RIGHT = '๐Ÿ‘‰';
3249

3350
const FIRE = '๐Ÿ”ฅ';
3451
const SNOW = 'โ„';
3552
const WATER = '๐Ÿ’ง';
3653
const FLASH = 'โšก';
3754

55+
const EYE = '๐Ÿ‘€';
3856
const HEART = '๐Ÿ’–';
3957

4058
const SUC = 'โœ…';
@@ -55,6 +73,7 @@ class EmojiSymbol
5573
const SUN = '๐ŸŒž';
5674
const STAR = 'โญ';
5775
const MOON = '๐ŸŒœ';
76+
const EARTH = '๐ŸŒ';
5877

5978
/**
6079
* @return array

0 commit comments

Comments
ย (0)