@@ -54,9 +54,9 @@ public function getContext()
5454 }
5555
5656 /**
57- * @param array| Completion $array
57+ * @param Completion[] $array
5858 */
59- public function addHandlers ($ array )
59+ public function addHandlers (array $ array )
6060 {
6161 $ this ->helpers = array_merge ($ this ->helpers , $ array );
6262 }
@@ -92,9 +92,11 @@ public function runCompletion()
9292 );
9393
9494 foreach ($ process as $ methodName ) {
95- if (is_array ($ result = $ this ->{$ methodName }())) {
95+ $ result = $ this ->{$ methodName }();
96+
97+ if (false !== $ result ) {
9698 // Return the result of the first completion mode that matches
97- return $ this ->filterResults ($ result );
99+ return $ this ->filterResults (( array ) $ result );
98100 }
99101 }
100102
@@ -284,11 +286,13 @@ protected function getCompletionHelper($name, $type)
284286 }
285287 }
286288 }
289+
290+ return null ;
287291 }
288292
289293 /**
290294 * @param InputOption $option
291- * @return array|mixed
295+ * @return array|false
292296 */
293297 protected function completeOption (InputOption $ option )
294298 {
@@ -299,6 +303,8 @@ protected function completeOption(InputOption $option)
299303 if ($ this ->command instanceof CompletionAwareInterface) {
300304 return $ this ->command ->completeOptionValues ($ option ->getName (), $ this ->context );
301305 }
306+
307+ return false ;
302308 }
303309
304310 /**
@@ -331,7 +337,6 @@ protected function mapArgumentsToWords($argumentDefinitions)
331337 }
332338
333339 foreach ($ this ->context ->getWords () as $ wordIndex => $ word ) {
334-
335340 // Skip program name, command name, options, and option values
336341 if ($ wordIndex < 2
337342 || ($ word && '- ' === $ word [0 ])
@@ -369,6 +374,11 @@ protected function filterResults(array $array)
369374 });
370375 }
371376
377+ /**
378+ * Returns list of all options.
379+ *
380+ * @return InputOption[]
381+ */
372382 protected function getAllOptions ()
373383 {
374384 return array_merge (
0 commit comments