@@ -53,20 +53,6 @@ abstract class AbstractApplication implements ApplicationInterface
5353 'list ' => 'List all group and alone commands ' ,
5454 ];
5555
56- /**
57- * @var int[]
58- */
59- protected static $ globalOptionNames = [
60- 'debug ' => 1 ,
61- 'profile ' => 1 ,
62- 'no-color ' => 1 ,
63- 'h ' => 1 ,
64- 'help ' => 1 ,
65- 'V ' => 1 ,
66- 'version ' => 1 ,
67- 'no-interactive ' => 1 ,
68- ];
69-
7056 /** @var array */
7157 protected static $ globalOptions = [
7258 '--debug ' => 'Setting the application runtime debug level(0 - 4) ' ,
@@ -96,8 +82,9 @@ abstract class AbstractApplication implements ApplicationInterface
9682 'updateAt ' => '2019.01.01 ' ,
9783 'rootPath ' => '' ,
9884 'strictMode ' => false ,
99- 'interactive ' => true ,
10085 'hideRootPath ' => true ,
86+ // global options
87+ 'no-interactive ' => true ,
10188
10289 // 'timeZone' => 'Asia/Shanghai',
10390 // 'env' => 'prod', // dev test prod
@@ -169,7 +156,7 @@ protected function init(): void
169156 */
170157 public static function isGlobalOption (string $ name ): bool
171158 {
172- return isset (self :: $ globalOptionNames [$ name ]);
159+ return isset (GlobalOption:: KEY_MAP [$ name ]);
173160 }
174161
175162 /**
@@ -563,7 +550,9 @@ public function isStrictMode(): bool
563550 */
564551 public function getVerbLevel (): int
565552 {
566- return (int )$ this ->input ->getLongOpt ('debug ' , (int )$ this ->config ['debug ' ]);
553+ $ key = GlobalOption::DEBUG ;
554+
555+ return (int )$ this ->input ->getLongOpt ($ key , (int )$ this ->config [$ key ]);
567556 }
568557
569558 /**
@@ -573,7 +562,10 @@ public function getVerbLevel(): int
573562 */
574563 public function isProfile (): bool
575564 {
576- return (bool )$ this ->input ->getOpt ('profile ' , $ this ->getParam ('profile ' , false ));
565+ $ key = GlobalOption::PROFILE ;
566+ $ def = (bool )$ this ->getParam ($ key , false );
567+
568+ return $ this ->input ->getBoolOpt ($ key , $ def );
577569 }
578570
579571 /**
@@ -583,8 +575,9 @@ public function isProfile(): bool
583575 */
584576 public function isInteractive (): bool
585577 {
586- $ key = 'no-interactive ' ;
587- $ val = (bool )$ this ->input ->getOpt ($ key , $ this ->getParam ($ key , true ));
578+ $ key = GlobalOption::NO_INTERACTIVE ;
579+ $ def = (bool )$ this ->getParam ($ key , true );
580+ $ val = $ this ->input ->getBoolOpt ($ key , $ def );
588581
589582 return $ val === false ;
590583 }
0 commit comments