Skip to content

Commit 66b727e

Browse files
committed
run code inspection check. fix some errors
1 parent 4237bdc commit 66b727e

File tree

6 files changed

+82
-85
lines changed

6 files changed

+82
-85
lines changed

src/Cli.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public static function parseArgv(array $noValues = [], $mergeOpts = false): arra
200200
$value = true;
201201

202202
// long-opt: (--<opt>)
203-
if ($opt{0} === '-') {
203+
if (\strpos($opt, '-') === 0) {
204204
$isLong = true;
205205
$opt = substr($opt, 1);
206206

@@ -238,14 +238,11 @@ public static function parseArgv(array $noValues = [], $mergeOpts = false): arra
238238
}
239239

240240
// arguments: param doesn't belong to any option, define it is args
241+
} elseif (strpos($p, '=') !== false) { // value specified inline (<arg>=<value>)
242+
list($name, $value) = explode('=', $p, 2);
243+
$args[$name] = $value;
241244
} else {
242-
// value specified inline (<arg>=<value>)
243-
if (strpos($p, '=') !== false) {
244-
list($name, $value) = explode('=', $p, 2);
245-
$args[$name] = $value;
246-
} else {
247-
$args[] = $p;
248-
}
245+
$args[] = $p;
249246
}
250247
}
251248

src/Color.php

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,63 +34,63 @@
3434
*/
3535
class Color
3636
{
37-
const NORMAL = 0;
37+
public const NORMAL = 0;
3838

3939
// Foreground color
40-
const FG_BLACK = 30;
41-
const FG_RED = 31;
42-
const FG_GREEN = 32;
43-
const FG_BROWN = 33; // like yellow
44-
const FG_BLUE = 34;
45-
const FG_CYAN = 36;
46-
const FG_WHITE = 37;
47-
const FG_DEFAULT = 39;
40+
public const FG_BLACK = 30;
41+
public const FG_RED = 31;
42+
public const FG_GREEN = 32;
43+
public const FG_BROWN = 33; // like yellow
44+
public const FG_BLUE = 34;
45+
public const FG_CYAN = 36;
46+
public const FG_WHITE = 37;
47+
public const FG_DEFAULT = 39;
4848

4949
// extra Foreground color
50-
const FG_DARK_GRAY = 90;
51-
const FG_LIGHT_RED = 91;
52-
const FG_LIGHT_GREEN = 92;
53-
const FG_LIGHT_YELLOW = 93;
54-
const FG_LIGHT_BLUE = 94;
55-
const FG_LIGHT_MAGENTA = 95;
56-
const FG_LIGHT_CYAN = 96;
57-
const FG_WHITE_W = 97;
50+
public const FG_DARK_GRAY = 90;
51+
public const FG_LIGHT_RED = 91;
52+
public const FG_LIGHT_GREEN = 92;
53+
public const FG_LIGHT_YELLOW = 93;
54+
public const FG_LIGHT_BLUE = 94;
55+
public const FG_LIGHT_MAGENTA = 95;
56+
public const FG_LIGHT_CYAN = 96;
57+
public const FG_WHITE_W = 97;
5858

5959
// Background color
60-
const BG_BLACK = 40;
61-
const BG_RED = 41;
62-
const BG_GREEN = 42;
63-
const BG_BROWN = 43; // like yellow
64-
const BG_BLUE = 44;
65-
const BG_CYAN = 46;
66-
const BG_WHITE = 47;
67-
const BG_DEFAULT = 49;
60+
public const BG_BLACK = 40;
61+
public const BG_RED = 41;
62+
public const BG_GREEN = 42;
63+
public const BG_BROWN = 43; // like yellow
64+
public const BG_BLUE = 44;
65+
public const BG_CYAN = 46;
66+
public const BG_WHITE = 47;
67+
public const BG_DEFAULT = 49;
6868

6969
// extra Background color
70-
const BG_DARK_GRAY = 100;
71-
const BG_LIGHT_RED = 101;
72-
const BG_LIGHT_GREEN = 102;
73-
const BG_LIGHT_YELLOW = 103;
74-
const BG_LIGHT_BLUE = 104;
75-
const BG_LIGHT_MAGENTA = 105;
76-
const BG_LIGHT_CYAN = 106;
77-
const BG_WHITE_W = 107;
70+
public const BG_DARK_GRAY = 100;
71+
public const BG_LIGHT_RED = 101;
72+
public const BG_LIGHT_GREEN = 102;
73+
public const BG_LIGHT_YELLOW = 103;
74+
public const BG_LIGHT_BLUE = 104;
75+
public const BG_LIGHT_MAGENTA = 105;
76+
public const BG_LIGHT_CYAN = 106;
77+
public const BG_WHITE_W = 107;
7878

7979
// color option
80-
const BOLD = 1; // 加粗
81-
const FUZZY = 2; // 模糊(不是所有的终端仿真器都支持)
82-
const ITALIC = 3; // 斜体(不是所有的终端仿真器都支持)
83-
const UNDERSCORE = 4; // 下划线
84-
const BLINK = 5; // 闪烁
85-
const REVERSE = 7; // 颠倒的 交换背景色与前景色
86-
const CONCEALED = 8; // 隐匿的
80+
public const BOLD = 1; // 加粗
81+
public const FUZZY = 2; // 模糊(不是所有的终端仿真器都支持)
82+
public const ITALIC = 3; // 斜体(不是所有的终端仿真器都支持)
83+
public const UNDERSCORE = 4; // 下划线
84+
public const BLINK = 5; // 闪烁
85+
public const REVERSE = 7; // 颠倒的 交换背景色与前景色
86+
public const CONCEALED = 8; // 隐匿的
8787

8888
/**
8989
* some styles
9090
* custom style: fg;bg;opt
9191
* @var array
9292
*/
93-
const STYLES = [
93+
public const STYLES = [
9494
// basic
9595
'red' => '0;31',
9696
'blue' => '0;34',
@@ -156,17 +156,17 @@ class Color
156156
/**
157157
* Regex to match tags
158158
*/
159-
const COLOR_TAG = '/<([a-z=;]+)>(.*?)<\/\\1>/s';
159+
public const COLOR_TAG = '/<([a-z=;]+)>(.*?)<\/\\1>/s';
160160

161161
/**
162162
* Regex used for removing color codes
163163
*/
164-
const STRIP_TAG = '/<[\/]?[a-zA-Z=;]+>/';
164+
public const STRIP_TAG = '/<[\/]?[a-zA-Z=;]+>/';
165165

166166
/**
167167
* CLI color template
168168
*/
169-
const COLOR_TPL = "\033[%sm%s\033[0m";
169+
public const COLOR_TPL = "\033[%sm%s\033[0m";
170170

171171
/**
172172
* @param string $method

src/Console.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class Console extends Cli
1616
{
17-
const LOG_LEVEL2TAG = [
17+
public const LOG_LEVEL2TAG = [
1818
'info' => 'info',
1919
'warn' => 'warning',
2020
'warning' => 'warning',
@@ -45,7 +45,7 @@ public static function log(string $msg, array $data = [], string $type = 'info',
4545
$userOpts = [];
4646

4747
foreach ($opts as $n => $v) {
48-
if (\is_numeric($n) || $n[0] === '_') {
48+
if (\is_numeric($n) || \strpos($n, '_') === 0) {
4949
$userOpts[] = "[$v]";
5050
} else {
5151
$userOpts[] = "[$n:$v]";

src/Download.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*/
1515
final class Download
1616
{
17-
const PROGRESS_TEXT = 'text';
18-
const PROGRESS_BAR = 'bar';
17+
public const PROGRESS_TEXT = 'text';
18+
public const PROGRESS_BAR = 'bar';
1919

2020
/** @var int */
2121
private $fileSize;

src/Highlighter.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*/
1717
class Highlighter
1818
{
19-
const TOKEN_DEFAULT = 'token_default';
20-
const TOKEN_COMMENT = 'token_comment';
21-
const TOKEN_STRING = 'token_string';
22-
const TOKEN_HTML = 'token_html';
23-
const TOKEN_KEYWORD = 'token_keyword';
24-
25-
const ACTUAL_LINE_MARK = 'actual_line_mark';
26-
const LINE_NUMBER = 'line_number';
19+
public const TOKEN_DEFAULT = 'token_default';
20+
public const TOKEN_COMMENT = 'token_comment';
21+
public const TOKEN_STRING = 'token_string';
22+
public const TOKEN_HTML = 'token_html';
23+
public const TOKEN_KEYWORD = 'token_keyword';
24+
25+
public const ACTUAL_LINE_MARK = 'actual_line_mark';
26+
public const LINE_NUMBER = 'line_number';
2727

2828
// @var Style
2929
//private $color;

src/Terminal.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@
1818
*/
1919
final class Terminal
2020
{
21-
const BEGIN_CHAR = "\033[";
22-
const END_CHAR = "\033[0m";
21+
public const BEGIN_CHAR = "\033[";
22+
public const END_CHAR = "\033[0m";
2323

2424
// Control cursor code name list. more @see [[self::$ctrlCursorCodes]]
25-
const CUR_HIDE = 'hide';
26-
const CUR_SHOW = 'show';
27-
const CUR_SAVE_POSITION = 'savePosition';
28-
const CUR_RESTORE_POSITION = 'restorePosition';
29-
const CUR_UP = 'up';
30-
const CUR_DOWN = 'down';
31-
const CUR_FORWARD = 'forward';
32-
const CUR_BACKWARD = 'backward';
33-
const CUR_NEXT_LINE = 'nextLine';
34-
const CUR_PREV_LINE = 'prevLine';
35-
const CUR_COORDINATE = 'coordinate';
25+
public const CUR_HIDE = 'hide';
26+
public const CUR_SHOW = 'show';
27+
public const CUR_SAVE_POSITION = 'savePosition';
28+
public const CUR_RESTORE_POSITION = 'restorePosition';
29+
public const CUR_UP = 'up';
30+
public const CUR_DOWN = 'down';
31+
public const CUR_FORWARD = 'forward';
32+
public const CUR_BACKWARD = 'backward';
33+
public const CUR_NEXT_LINE = 'nextLine';
34+
public const CUR_PREV_LINE = 'prevLine';
35+
public const CUR_COORDINATE = 'coordinate';
3636

3737
// Control screen code name list. more @see [[self::$ctrlScreenCodes]]
38-
const CLEAR = 'clear';
39-
const CLEAR_BEFORE_CURSOR = 'clearBeforeCursor';
40-
const CLEAR_LINE = 'clearLine';
41-
const CLEAR_LINE_BEFORE_CURSOR = 'clearLineBeforeCursor';
42-
const CLEAR_LINE_AFTER_CURSOR = 'clearLineAfterCursor';
43-
44-
const SCROLL_UP = 'scrollUp';
45-
const SCROLL_DOWN = 'scrollDown';
38+
public const CLEAR = 'clear';
39+
public const CLEAR_BEFORE_CURSOR = 'clearBeforeCursor';
40+
public const CLEAR_LINE = 'clearLine';
41+
public const CLEAR_LINE_BEFORE_CURSOR = 'clearLineBeforeCursor';
42+
public const CLEAR_LINE_AFTER_CURSOR = 'clearLineAfterCursor';
43+
44+
public const SCROLL_UP = 'scrollUp';
45+
public const SCROLL_DOWN = 'scrollDown';
4646

4747
/**
4848
* current class's instance

0 commit comments

Comments
 (0)