Skip to content

Commit 74de6ec

Browse files
bug #41675 [Runtime] fix overriding --env|-e with single-command apps (nicolas-grekas)
This PR was merged into the 5.3 branch. Discussion ---------- [Runtime] fix overriding --env|-e with single-command apps | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #41658 | License | MIT | Doc PR | - Commits ------- 25fb2f7 [Runtime] fix overriding --env|-e with single-command apps
2 parents 57e1952 + 25fb2f7 commit 74de6ec

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Symfony/Component/Runtime/SymfonyRuntime.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function getRunner(?object $application): RunnerInterface
131131
}
132132

133133
$console->setDefaultCommand($application->getName(), true);
134+
$console->getDefinition()->addOptions($application->getDefinition()->getOptions());
134135

135136
return $this->getRunner($console);
136137
}

src/Symfony/Component/Runtime/Tests/phpt/command.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
use Symfony\Component\Console\Command\Command;
44
use Symfony\Component\Console\Input\InputInterface;
5+
use Symfony\Component\Console\Input\InputOption;
56
use Symfony\Component\Console\Output\OutputInterface;
67

78
require __DIR__.'/autoload.php';
89

910
return function (Command $command, InputInterface $input, OutputInterface $output, array $context) {
10-
$command->setCode(function () use ($output, $context) {
11-
$output->write('OK Command '.$context['SOME_VAR']);
12-
});
11+
$command->addOption('hello', 'e', InputOption::VALUE_REQUIRED, 'How should I greet?', 'OK');
1312

14-
return $command;
13+
return $command->setCode(function () use ($input, $output, $context) {
14+
$output->write($input->getOption('hello').' Command '.$context['SOME_VAR']);
15+
});
1516
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy