@@ -26,7 +26,7 @@ public function doRun()
2626 try {
2727 $ status = $ this ->dispatch ();
2828 } catch (\Exception $ e ) {
29- $ status = - $ e ->getCode ();
29+ $ status = -$ e ->getCode ();
3030 $ this ->dispatchExHandler ($ e );
3131 }
3232
@@ -49,7 +49,7 @@ public function dispatch()
4949
5050 //// is a command name
5151
52- if ( isset ($ this ->commands [$ name ]) ) {
52+ if (isset ($ this ->commands [$ name ])) {
5353 return $ this ->runCommand ($ name , true );
5454 }
5555
@@ -58,16 +58,16 @@ public function dispatch()
5858 $ action = '' ;
5959
6060 // like 'home/index'
61- if ( strpos ($ name , $ sep ) > 0 ) {
61+ if (strpos ($ name , $ sep ) > 0 ) {
6262 $ input = array_filter (explode ($ sep , $ name ));
6363 [$ name , $ action ] = count ($ input ) > 2 ? array_splice ($ input , 2 ) : $ input ;
6464 }
6565
66- if ( isset ($ this ->controllers [$ name ]) ) {
66+ if (isset ($ this ->controllers [$ name ])) {
6767 return $ this ->runAction ($ name , $ action , true );
6868 }
6969
70- if ( $ cb = self ::$ hooks [self ::ON_NOT_FOUND ] ) {
70+ if ($ cb = self ::$ hooks [self ::ON_NOT_FOUND ]) {
7171 $ cb ($ command , $ this );
7272 } else {
7373 // not match, output error message
@@ -80,31 +80,31 @@ public function dispatch()
8080
8181 /**
8282 * run a command
83- * @param string $name Command name
84- * @param bool $believable The `$name` is believable
83+ * @param string $name Command name
84+ * @param bool $believable The `$name` is believable
8585 * @return mixed
8686 */
8787 public function runCommand ($ name , $ believable = false )
8888 {
8989 // if $believable = true, will skip check.
90- if ( !$ believable && !isset ($ this ->commands [$ name ]) ) {
90+ if (!$ believable && !isset ($ this ->commands [$ name ])) {
9191 throw new \InvalidArgumentException ("The console independent-command [ $ name] not exists! " );
9292 }
9393
9494 // Command class
9595 $ handler = $ this ->commands [$ name ];
9696
97- if ( is_object ($ handler ) && ($ handler instanceof \Closure) ) {
97+ if (is_object ($ handler ) && ($ handler instanceof \Closure)) {
9898 $ status = $ handler ($ this ->input , $ this ->output );
9999 } else {
100- if ( !class_exists ($ handler ) ) {
100+ if (!class_exists ($ handler )) {
101101 throw new \InvalidArgumentException ("The console command class [ $ handler] not exists! " );
102102 }
103103
104104 /** @var Command $object */
105105 $ object = new $ handler ($ this ->input , $ this ->output );
106106
107- if ( !($ object instanceof Command ) ) {
107+ if (!($ object instanceof Command) ) {
108108 throw new \InvalidArgumentException ("The console command class [ $ handler] must instanceof the " . Command::class);
109109 }
110110
@@ -115,30 +115,30 @@ public function runCommand($name, $believable = false)
115115 }
116116
117117 /**
118- * @param string $name Controller name
118+ * @param string $name Controller name
119119 * @param string $action
120- * @param bool $believable The `$name` is believable
120+ * @param bool $believable The `$name` is believable
121121 * @return mixed
122122 */
123123 public function runAction ($ name , $ action , $ believable = false )
124124 {
125125 // if $believable = true, will skip check.
126- if ( !$ believable && !isset ($ this ->controllers [$ name ]) ) {
126+ if (!$ believable && !isset ($ this ->controllers [$ name ])) {
127127 throw new \InvalidArgumentException ("The console controller-command [ $ name] not exists! " );
128128 }
129129
130130 // Controller class
131131 $ controller = $ this ->controllers [$ name ];
132132
133- if ( !class_exists ($ controller ) ) {
133+ if (!class_exists ($ controller )) {
134134 throw new \InvalidArgumentException ("The console controller class [ $ controller] not exists! " );
135135 }
136136
137137 /** @var Controller $object */
138138 $ object = new $ controller ($ this ->input , $ this ->output );
139139 $ object ->setName ($ name );
140140
141- if ( !($ object instanceof Controller) ) {
141+ if (!($ object instanceof Controller)) {
142142 throw new \InvalidArgumentException ("The console controller class [ $ object] must instanceof the " . Controller::class);
143143 }
144144
@@ -150,12 +150,12 @@ public function runAction($name, $action, $believable = false)
150150 * @param \Exception $e
151151 * @throws \Exception
152152 */
153- public function dispatchExHandler (\Exception $ e )
153+ public function dispatchExHandler (\Exception $ e )
154154 {
155155 // $this->logger->ex($e);
156156
157157 // open debug, throw exception
158- if ( $ this ->isDebug () ) {
158+ if ($ this ->isDebug ()) {
159159 throw $ e ;
160160 }
161161
@@ -243,7 +243,7 @@ public function showCommandList($quit = true)
243243 $ controllers = $ this ->controllers ;
244244 ksort ($ controllers );
245245 foreach ($ controllers as $ name => $ controller ) {
246- $ controllerArr [$ name ] = $ controller ::DESCRIPTION ? : 'No description ' ;
246+ $ controllerArr [$ name ] = $ controller ::DESCRIPTION ?: 'No description ' ;
247247 }
248248
249249 // all independent commands
@@ -252,11 +252,11 @@ public function showCommandList($quit = true)
252252 foreach ($ commands as $ name => $ command ) {
253253 $ desc = 'No description ' ;
254254
255- if ( is_subclass_of ($ command , Command::class) ) {
256- $ desc = $ command ::DESCRIPTION ? : 'No description ' ;
257- } else if ( is_string ($ command ) ) {
255+ if (is_subclass_of ($ command , Command::class)) {
256+ $ desc = $ command ::DESCRIPTION ?: 'No description ' ;
257+ } else if (is_string ($ command )) {
258258 $ desc = 'A handler: ' . $ command ;
259- } else if ( is_object ($ command ) ) {
259+ } else if (is_object ($ command )) {
260260 $ desc = $ command instanceof \Closure ? 'A Closure ' : 'A Object ' ;
261261 }
262262
0 commit comments