Skip to content

Commit 5af47c4

Browse files
committed
Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)"
This reverts commit b8b6774, reversing changes made to 8279055.
1 parent 6b4cfd6 commit 5af47c4

File tree

3 files changed

+5
-45
lines changed

3 files changed

+5
-45
lines changed

src/Symfony/Component/Console/Application.php

-4
Original file line numberDiff line numberDiff line change
@@ -859,10 +859,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
859859
// ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
860860
}
861861

862-
// don't bind the input again as it would override any input argument/option set from the command event in
863-
// addition to being useless
864-
$command->setInputBound(true);
865-
866862
$event = new ConsoleCommandEvent($command, $input, $output);
867863
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
868864

src/Symfony/Component/Console/Command/Command.php

+5-16
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Command
4242
private $ignoreValidationErrors = false;
4343
private $applicationDefinitionMerged = false;
4444
private $applicationDefinitionMergedWithArgs = false;
45-
private $inputBound = false;
4645
private $code;
4746
private $synopsis = array();
4847
private $usages = array();
@@ -219,13 +218,11 @@ public function run(InputInterface $input, OutputInterface $output)
219218
$this->mergeApplicationDefinition();
220219

221220
// bind the input against the command specific arguments/options
222-
if (!$this->inputBound) {
223-
try {
224-
$input->bind($this->definition);
225-
} catch (ExceptionInterface $e) {
226-
if (!$this->ignoreValidationErrors) {
227-
throw $e;
228-
}
221+
try {
222+
$input->bind($this->definition);
223+
} catch (ExceptionInterface $e) {
224+
if (!$this->ignoreValidationErrors) {
225+
throw $e;
229226
}
230227
}
231228

@@ -681,14 +678,6 @@ public function asXml($asDom = false)
681678
return $output->fetch();
682679
}
683680

684-
/**
685-
* @internal
686-
*/
687-
public function setInputBound($inputBound)
688-
{
689-
$this->inputBound = $inputBound;
690-
}
691-
692681
/**
693682
* Validates a command name.
694683
*

src/Symfony/Component/Console/Tests/ApplicationTest.php

-25
Original file line numberDiff line numberDiff line change
@@ -1113,31 +1113,6 @@ public function testRunWithDispatcherAddingInputOptions()
11131113
$this->assertEquals('some test value', $extraValue);
11141114
}
11151115

1116-
public function testUpdateInputFromConsoleCommandEvent()
1117-
{
1118-
$dispatcher = $this->getDispatcher();
1119-
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) {
1120-
$event->getInput()->setOption('extra', 'overriden');
1121-
});
1122-
1123-
$application = new Application();
1124-
$application->setDispatcher($dispatcher);
1125-
$application->setAutoExit(false);
1126-
1127-
$application
1128-
->register('foo')
1129-
->addOption('extra', null, InputOption::VALUE_REQUIRED)
1130-
->setCode(function (InputInterface $input, OutputInterface $output) {
1131-
$output->write('foo.');
1132-
})
1133-
;
1134-
1135-
$tester = new ApplicationTester($application);
1136-
$tester->run(array('command' => 'foo', '--extra' => 'original'));
1137-
1138-
$this->assertEquals('overriden', $tester->getInput()->getOption('extra'));
1139-
}
1140-
11411116
public function testTerminalDimensions()
11421117
{
11431118
$application = new Application();

0 commit comments

Comments
 (0)