File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -562,6 +562,16 @@ public function find($name)
562
562
throw new \InvalidArgumentException ($ message );
563
563
}
564
564
565
+ // filter out aliases for commands which are already on the list
566
+ if (count ($ commands ) > 1 ) {
567
+ $ commandList = $ this ->commands ;
568
+ $ commands = array_filter ($ commands , function ($ nameOrAlias ) use ($ commandList , $ commands ) {
569
+ $ commandName = $ commandList [$ nameOrAlias ]->getName ();
570
+
571
+ return $ commandName === $ nameOrAlias || !in_array ($ commandName , $ commands );
572
+ });
573
+ }
574
+
565
575
$ exact = in_array ($ name , $ commands , true );
566
576
if (count ($ commands ) > 1 && !$ exact ) {
567
577
$ suggestions = $ this ->getAbbreviationSuggestions (array_values ($ commands ));
Original file line number Diff line number Diff line change @@ -393,6 +393,19 @@ public function testFindAlternativeCommands()
393
393
}
394
394
}
395
395
396
+ public function testFindAlternativeCommandsWithAnAlias ()
397
+ {
398
+ $ fooCommand = new \FooCommand ();
399
+ $ fooCommand ->setAliases (array ('foo2 ' ));
400
+
401
+ $ application = new Application ();
402
+ $ application ->add ($ fooCommand );
403
+
404
+ $ result = $ application ->find ('foo ' );
405
+
406
+ $ this ->assertSame ($ fooCommand , $ result );
407
+ }
408
+
396
409
public function testFindAlternativeNamespace ()
397
410
{
398
411
$ application = new Application ();
You can’t perform that action at this time.
0 commit comments