@@ -68,13 +68,13 @@ public function __construct()
6868 {
6969 $ this ->pwd = $ this ->getPwd ();
7070
71- [
71+ list (
7272 $ this ->fullScript ,
7373 $ this ->script ,
7474 $ this ->args ,
7575 $ this ->sOpts ,
7676 $ this ->lOpts
77- ] = self ::parseOptArgs ();
77+ ) = self ::parseOptArgs ();
7878
7979 // collect command `server`
8080 $ this ->command = isset ($ this ->args [0 ]) ? array_shift ($ this ->args ) : '' ;
@@ -86,7 +86,7 @@ public function __construct()
8686 * @param bool $nl true 会添加换行符 false 原样输出,不添加换行符
8787 * @return string
8888 */
89- public function read ($ question = null , $ nl = false )
89+ public function read ($ question = null , $ nl = false ): string
9090 {
9191 fwrite (STDOUT , $ question . ($ nl ? "\n" : '' ));
9292
@@ -101,7 +101,7 @@ public function read($question = null, $nl = false)
101101 * @param string|int $name
102102 * @return bool
103103 */
104- public function hasArg ($ name )
104+ public function hasArg ($ name ): bool
105105 {
106106 return isset ($ this ->args [$ name ]);
107107 }
@@ -199,7 +199,7 @@ public function getOpt(string $name, $default = null)
199199 * @param bool $default
200200 * @return bool
201201 */
202- public function boolOpt (string $ name , $ default = false )
202+ public function boolOpt (string $ name , $ default = false ): bool
203203 {
204204 return (bool )$ this ->getOpt ($ name , $ default );
205205 }
@@ -209,7 +209,7 @@ public function boolOpt(string $name, $default = false)
209209 * @param $name
210210 * @return bool
211211 */
212- public function hasOpt (string $ name )
212+ public function hasOpt (string $ name ): bool
213213 {
214214 return isset ($ this ->sOpts [$ name ]) || isset ($ this ->lOpts [$ name ]);
215215 }
@@ -255,7 +255,7 @@ public function sOpt($name, $default = null)
255255 * @param $name
256256 * @return bool
257257 */
258- public function hasSOpt (string $ name )
258+ public function hasSOpt (string $ name ): bool
259259 {
260260 return isset ($ this ->sOpts [$ name ]);
261261 }
@@ -266,7 +266,7 @@ public function hasSOpt(string $name)
266266 * @param bool $default
267267 * @return bool
268268 */
269- public function sBoolOpt (string $ name , $ default = false )
269+ public function sBoolOpt (string $ name , $ default = false ): bool
270270 {
271271 $ val = $ this ->sOpt ($ name );
272272
@@ -291,7 +291,7 @@ public function lOpt($name, $default = null)
291291 * @param $name
292292 * @return bool
293293 */
294- public function hasLOpt (string $ name )
294+ public function hasLOpt (string $ name ): bool
295295 {
296296 return isset ($ this ->lOpts [$ name ]);
297297 }
@@ -302,7 +302,7 @@ public function hasLOpt(string $name)
302302 * @param bool $default
303303 * @return bool
304304 */
305- public function lBoolOpt (string $ name , $ default = false )
305+ public function lBoolOpt (string $ name , $ default = false ): bool
306306 {
307307 $ val = $ this ->lOpt ($ name );
308308
@@ -428,7 +428,7 @@ public function getInputStream()
428428 /**
429429 * @return string
430430 */
431- public function getPwd ()
431+ public function getPwd (): string
432432 {
433433 if (!$ this ->pwd ) {
434434 $ this ->pwd =getcwd ();
@@ -467,7 +467,7 @@ public function getPwd()
467467 * @param bool $mergeOpts Whether merge short-opts and long-opts
468468 * @return array
469469 */
470- public static function parseOptArgs (array $ noValues = [], $ mergeOpts = false )
470+ public static function parseOptArgs (array $ noValues = [], $ mergeOpts = false ): array
471471 {
472472 $ params = $ GLOBALS ['argv ' ];
473473 reset ($ params );
@@ -490,12 +490,12 @@ public static function parseOptArgs(array $noValues = [], $mergeOpts = false)
490490
491491 // long-opt: value specified inline (--<opt>=<value>)
492492 if (strpos ($ opt , '= ' ) !== false ) {
493- [ $ opt , $ value] = explode ('= ' , $ opt , 2 );
493+ list ( $ opt , $ value) = explode ('= ' , $ opt , 2 );
494494 }
495495
496496 // short-opt: value specified inline (-<opt>=<value>)
497497 } elseif (strlen ($ opt ) > 2 && $ opt {1 } === '= ' ) {
498- [ $ opt , $ value] = explode ('= ' , $ opt , 2 );
498+ list ( $ opt , $ value) = explode ('= ' , $ opt , 2 );
499499 }
500500
501501 // check if next parameter is a descriptor or a value
@@ -523,7 +523,7 @@ public static function parseOptArgs(array $noValues = [], $mergeOpts = false)
523523 } else {
524524 // value specified inline (<arg>=<value>)
525525 if (strpos ($ p , '= ' ) !== false ) {
526- [ $ name , $ value] = explode ('= ' , $ p , 2 );
526+ list ( $ name , $ value) = explode ('= ' , $ p , 2 );
527527 $ args [$ name ] = self ::filterBool ($ value );
528528 } else {
529529 $ args [] = $ p ;
@@ -543,7 +543,7 @@ public static function parseOptArgs(array $noValues = [], $mergeOpts = false)
543543 /**
544544 * @param string|bool $val
545545 * @param bool $enable
546- * @return bool
546+ * @return bool|mixed
547547 */
548548 private static function filterBool ($ val , $ enable = true )
549549 {
0 commit comments