@@ -25,6 +25,7 @@ class Application extends AbstractApplication
2525 * @param string $name The controller name
2626 * @param string $class The controller class
2727 * @return static
28+ * @throws \InvalidArgumentException
2829 */
2930 public function controller (string $ name , string $ class = null )
3031 {
@@ -78,6 +79,7 @@ public function controllers(array $controllers)
7879 * @param string|\Closure|Command $handler
7980 * @param null|string $description
8081 * @return $this
82+ * @throws \InvalidArgumentException
8183 */
8284 public function command (string $ name , $ handler = null , $ description = null )
8385 {
@@ -97,15 +99,15 @@ public function command(string $name, $handler = null, $description = null)
9799 throw new \InvalidArgumentException ("Command ' $ name' have been registered! " );
98100 }
99101
100- if (is_string ($ handler )) {
102+ if (\ is_string ($ handler )) {
101103 if (!class_exists ($ handler )) {
102104 throw new \InvalidArgumentException ("The console command class [ $ handler] not exists! " );
103105 }
104106
105107 if (!is_subclass_of ($ handler , Command::class)) {
106108 throw new \InvalidArgumentException ('The console command class must is subclass of the: ' . Command::class);
107109 }
108- } elseif (!is_object ($ handler ) || !method_exists ($ handler , '__invoke ' )) {
110+ } elseif (!\ is_object ($ handler ) || !method_exists ($ handler , '__invoke ' )) {
109111 throw new \InvalidArgumentException (sprintf (
110112 'The console command handler must is an subclass of %s OR a Closure OR a object have method __invoke() ' ,
111113 Command::class
@@ -135,6 +137,7 @@ public function commands(array $commands)
135137 * @param string $name
136138 * @param mixed $handler
137139 * @return $this
140+ * @throws \InvalidArgumentException
138141 */
139142 public function addCommand (string $ name , $ handler = null )
140143 {
@@ -146,6 +149,7 @@ public function addCommand(string $name, $handler = null)
146149 * @param string $name
147150 * @param string|null $controller
148151 * @return static
152+ * @throws \InvalidArgumentException
149153 */
150154 public function addGroup (string $ name , string $ controller = null )
151155 {
@@ -158,6 +162,7 @@ public function addGroup(string $name, string $controller = null)
158162
159163 /**
160164 * @inheritdoc
165+ * @throws \InvalidArgumentException
161166 */
162167 protected function dispatch ($ name )
163168 {
@@ -176,7 +181,7 @@ protected function dispatch($name)
176181 // like 'home/index'
177182 if (strpos ($ name , $ sep ) > 0 ) {
178183 $ input = array_filter (explode ($ sep , $ name ));
179- list ($ name , $ action ) = count ($ input ) > 2 ? array_splice ($ input , 2 ) : $ input ;
184+ list ($ name , $ action ) = \ count ($ input ) > 2 ? array_splice ($ input , 2 ) : $ input ;
180185 }
181186
182187 if ($ this ->isController ($ name )) {
@@ -200,7 +205,7 @@ protected function dispatch($name)
200205 }
201206
202207 if ($ similar ) {
203- $ this ->write (sprintf (' Maybe what you mean is: <info>%s</info>' , implode (', ' , $ similar )));
208+ $ this ->write (sprintf ("\n Maybe what you mean is:\n <info>%s</info>" , implode (', ' , $ similar )));
204209 } else {
205210 $ this ->showCommandList (false );
206211 }
@@ -214,6 +219,7 @@ protected function dispatch($name)
214219 * @param string $name Command name
215220 * @param bool $believable The `$name` is believable
216221 * @return mixed
222+ * @throws \InvalidArgumentException
217223 */
218224 public function runCommand ($ name , $ believable = false )
219225 {
@@ -225,7 +231,7 @@ public function runCommand($name, $believable = false)
225231 /** @var \Closure|string $handler Command class */
226232 $ handler = $ this ->commands [$ name ];
227233
228- if (is_object ($ handler ) && method_exists ($ handler , '__invoke ' )) {
234+ if (\ is_object ($ handler ) && method_exists ($ handler , '__invoke ' )) {
229235 $ status = $ handler ($ this ->input , $ this ->output );
230236 } else {
231237 if (!class_exists ($ handler )) {
@@ -253,6 +259,7 @@ public function runCommand($name, $believable = false)
253259 * @param bool $believable The `$name` is believable
254260 * @param bool $standAlone
255261 * @return mixed
262+ * @throws \InvalidArgumentException
256263 */
257264 public function runAction ($ name , $ action , $ believable = false , $ standAlone = false )
258265 {
0 commit comments