Merge branch '3.4' into 4.4
* 3.4: Fix undefined index for inconsistent command name definition
This commit is contained in:
commit
bca14aa5f8
@ -513,6 +513,11 @@ class Application implements ResetInterface
|
|||||||
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
|
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the command has a different name than the one used at the command loader level
|
||||||
|
if (!isset($this->commands[$name])) {
|
||||||
|
throw new CommandNotFoundException(sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name));
|
||||||
|
}
|
||||||
|
|
||||||
$command = $this->commands[$name];
|
$command = $this->commands[$name];
|
||||||
|
|
||||||
if ($this->wantHelps) {
|
if ($this->wantHelps) {
|
||||||
|
@ -1802,6 +1802,20 @@ class ApplicationTest extends TestCase
|
|||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
$tester->run(['command' => 'foo']);
|
$tester->run(['command' => 'foo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCommandNameMismatchWithCommandLoaderKeyThrows()
|
||||||
|
{
|
||||||
|
$this->expectException(CommandNotFoundException::class);
|
||||||
|
$this->expectExceptionMessage('The "test" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".');
|
||||||
|
|
||||||
|
$app = new Application();
|
||||||
|
$loader = new FactoryCommandLoader([
|
||||||
|
'test' => static function () { return new Command('test-command'); },
|
||||||
|
]);
|
||||||
|
|
||||||
|
$app->setCommandLoader($loader);
|
||||||
|
$app->get('test');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomApplication extends Application
|
class CustomApplication extends Application
|
||||||
|
Reference in New Issue
Block a user