Skip to content

Commit d1194ba

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [Translation][Lokalize] Configure `replace_breaks` to prevent issues with multilines translations Improve message when shell is not detected ensure docblock compatibility with PhpStan's docblock parser Fix signal handlers called after event listeners and skip exit
2 parents 90e03ec + ed30487 commit d1194ba

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Application.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,10 +986,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
986986
});
987987
}
988988
}
989-
990-
foreach ($commandSignals as $signal) {
991-
$this->signalRegistry->register($signal, [$command, 'handleSignal']);
992-
}
993989
}
994990

995991
if (null !== $this->dispatcher) {
@@ -1008,6 +1004,10 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
10081004
});
10091005
}
10101006
}
1007+
1008+
foreach ($commandSignals as $signal) {
1009+
$this->signalRegistry->register($signal, [$command, 'handleSignal']);
1010+
}
10111011
}
10121012

10131013
if (null === $this->dispatcher) {

Command/DumpCompletionCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
101101
if (!file_exists($completionFile)) {
102102
$supportedShells = $this->getSupportedShells();
103103

104-
($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output)
105-
->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
104+
if ($output instanceof ConsoleOutputInterface) {
105+
$output = $output->getErrorOutput();
106+
}
107+
if ($shell) {
108+
$output->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
109+
} else {
110+
$output->writeln(sprintf('<error>Shell not detected, Symfony shell completion only supports "%s").</>', implode('", "', $supportedShells)));
111+
}
106112

107113
return self::INVALID;
108114
}

Tests/ApplicationTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,21 @@ public function testSignalableCommandInterfaceWithoutSignals()
19751975
$this->assertSame(0, $application->run(new ArrayInput(['signal'])));
19761976
}
19771977

1978+
public function testSignalableCommandHandlerCalledAfterEventListener()
1979+
{
1980+
$command = new SignableCommand();
1981+
1982+
$subscriber = new SignalEventSubscriber();
1983+
1984+
$dispatcher = new EventDispatcher();
1985+
$dispatcher->addSubscriber($subscriber);
1986+
1987+
$application = $this->createSignalableApplication($command, $dispatcher);
1988+
$application->setSignalsToDispatchEvent(\SIGUSR1);
1989+
$this->assertSame(1, $application->run(new ArrayInput(['signal'])));
1990+
$this->assertSame([SignalEventSubscriber::class, SignableCommand::class], $command->signalHandlers);
1991+
}
1992+
19781993
/**
19791994
* @group tty
19801995
*/
@@ -2074,6 +2089,7 @@ public function isEnabled(): bool
20742089
class BaseSignableCommand extends Command
20752090
{
20762091
public $signaled = false;
2092+
public $signalHandlers = [];
20772093
public $loop = 1000;
20782094
private $emitsSignal;
20792095

@@ -2111,6 +2127,7 @@ public function getSubscribedSignals(): array
21112127
public function handleSignal(int $signal): void
21122128
{
21132129
$this->signaled = true;
2130+
$this->signalHandlers[] = __CLASS__;
21142131
}
21152132
}
21162133

@@ -2122,6 +2139,7 @@ public function onSignal(ConsoleSignalEvent $event): void
21222139
{
21232140
$this->signaled = true;
21242141
$event->getCommand()->signaled = true;
2142+
$event->getCommand()->signalHandlers[] = __CLASS__;
21252143
}
21262144

21272145
public static function getSubscribedEvents(): array

0 commit comments

Comments
 (0)