File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .DS_Store
12.idea
23composer.lock
34vendor
4- coverage
5+ coverage
Original file line number Diff line number Diff line change 11# Parable Console
22
3+ ## 0.6.1
4+
5+ _ Changes_
6+ - Small bugfix that crept up after splitting named commands and instantiated ones.
7+
38## 0.6.0
49
510_ Changes_
Original file line number Diff line number Diff line change @@ -102,6 +102,9 @@ public function getCommand(string $commandName): ?Command
102102 /** @var Command $command */
103103 $ command = $ this ->container ->get ($ this ->commandNames [$ commandName ]);
104104 $ this ->addCommand ($ command );
105+
106+ // Since we've instantiated now, we can lose the reference to the name alone
107+ unset($ this ->commandNames [$ commandName ]);
105108 }
106109
107110 return $ this ->commands [$ commandName ];
@@ -114,17 +117,20 @@ public function getCommands(): array
114117 {
115118 $ commands = [];
116119
117- foreach ($ this ->commands as $ commandName => $ command ) {
120+ foreach ($ this ->commandNames as $ commandName => $ className ) {
118121 $ commands [$ commandName ] = $ this ->getCommand ($ commandName );
119122 }
120123
121- return array_filter ($ commands );
124+ return array_filter (array_merge ( $ this -> commands , $ commands ) );
122125 }
123126
124127 public function removeCommandByName (string $ commandName ): void
125128 {
126129 if ($ this ->hasCommand ($ commandName )) {
127- unset($ this ->commands [$ commandName ]);
130+ unset(
131+ $ this ->commands [$ commandName ],
132+ $ this ->commandNames [$ commandName ]
133+ );
128134 }
129135 }
130136
Original file line number Diff line number Diff line change @@ -98,6 +98,20 @@ public function testGetCommand(): void
9898 self ::assertSame ('OK2 ' , ValueClass::get ());
9999 }
100100
101+ public function testGetCommandsGetsBothInstantiatedAndCommandNames (): void
102+ {
103+ $ application = $ this ->container ->buildAll (Application::class);
104+
105+ $ application ->addCommand ($ this ->command1 );
106+ $ application ->addCommandByNameAndClass ('test-command ' , TestCommand::class);
107+
108+ self ::assertCount (2 , $ application ->getCommands ());
109+
110+ foreach ($ application ->getCommands () as $ commandName => $ command ) {
111+ self ::assertInstanceOf (Command::class, $ command );
112+ }
113+ }
114+
101115 public function testAddCommand (): void
102116 {
103117 self ::assertFalse ($ this ->container ->has (TestCommand::class));
You can’t perform that action at this time.
0 commit comments