Skip to content

Commit 1aab387

Browse files
committed
Merge branch '6.1' into 6.2
* 6.1: [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 902b698 + d1194ba commit 1aab387

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
@@ -992,10 +992,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
992992
});
993993
}
994994
}
995-
996-
foreach ($commandSignals as $signal) {
997-
$this->signalRegistry->register($signal, [$command, 'handleSignal']);
998-
}
999995
}
1000996

1001997
if (null !== $this->dispatcher) {
@@ -1014,6 +1010,10 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
10141010
});
10151011
}
10161012
}
1013+
1014+
foreach ($commandSignals as $signal) {
1015+
$this->signalRegistry->register($signal, [$command, 'handleSignal']);
1016+
}
10171017
}
10181018

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

Command/DumpCompletionCommand.php

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

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

108114
return self::INVALID;
109115
}

Tests/ApplicationTest.php

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

1994+
public function testSignalableCommandHandlerCalledAfterEventListener()
1995+
{
1996+
$command = new SignableCommand();
1997+
1998+
$subscriber = new SignalEventSubscriber();
1999+
2000+
$dispatcher = new EventDispatcher();
2001+
$dispatcher->addSubscriber($subscriber);
2002+
2003+
$application = $this->createSignalableApplication($command, $dispatcher);
2004+
$application->setSignalsToDispatchEvent(\SIGUSR1);
2005+
$this->assertSame(1, $application->run(new ArrayInput(['signal'])));
2006+
$this->assertSame([SignalEventSubscriber::class, SignableCommand::class], $command->signalHandlers);
2007+
}
2008+
19942009
/**
19952010
* @group tty
19962011
*/
@@ -2090,6 +2105,7 @@ public function isEnabled(): bool
20902105
class BaseSignableCommand extends Command
20912106
{
20922107
public $signaled = false;
2108+
public $signalHandlers = [];
20932109
public $loop = 1000;
20942110
private $emitsSignal;
20952111

@@ -2127,6 +2143,7 @@ public function getSubscribedSignals(): array
21272143
public function handleSignal(int $signal): void
21282144
{
21292145
$this->signaled = true;
2146+
$this->signalHandlers[] = __CLASS__;
21302147
}
21312148
}
21322149

@@ -2138,6 +2155,7 @@ public function onSignal(ConsoleSignalEvent $event): void
21382155
{
21392156
$this->signaled = true;
21402157
$event->getCommand()->signaled = true;
2158+
$event->getCommand()->signalHandlers[] = __CLASS__;
21412159
}
21422160

21432161
public static function getSubscribedEvents(): array

0 commit comments

Comments
 (0)