Skip to content

Commit 6646c06

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [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 90cb7d3 + d4fab7f commit 6646c06

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

src/Symfony/Component/Console/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) {

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

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

96-
($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output)
97-
->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
96+
if ($output instanceof ConsoleOutputInterface) {
97+
$output = $output->getErrorOutput();
98+
}
99+
if ($shell) {
100+
$output->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
101+
} else {
102+
$output->writeln(sprintf('<error>Shell not detected, Symfony shell completion only supports "%s").</>', implode('", "', $supportedShells)));
103+
}
98104

99105
return self::INVALID;
100106
}

src/Symfony/Component/Console/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
*/
@@ -2073,6 +2088,7 @@ public function isEnabled(): bool
20732088
class BaseSignableCommand extends Command
20742089
{
20752090
public $signaled = false;
2091+
public $signalHandlers = [];
20762092
public $loop = 1000;
20772093
private $emitsSignal;
20782094

@@ -2113,6 +2129,7 @@ public function getSubscribedSignals(): array
21132129
public function handleSignal(int $signal): void
21142130
{
21152131
$this->signaled = true;
2132+
$this->signalHandlers[] = __CLASS__;
21162133
}
21172134
}
21182135

@@ -2124,6 +2141,7 @@ public function onSignal(ConsoleSignalEvent $event): void
21242141
{
21252142
$this->signaled = true;
21262143
$event->getCommand()->signaled = true;
2144+
$event->getCommand()->signalHandlers[] = __CLASS__;
21272145
}
21282146

21292147
public static function getSubscribedEvents(): array

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Dummy extends ParentDummy
8484
public $h;
8585

8686
/**
87-
* @var ?string|int
87+
* @var string|int|null
8888
*/
8989
public $i;
9090

src/Symfony/Component/Translation/Bridge/Lokalise/LokaliseProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ private function exportFiles(array $locales, array $domains): array
151151
'filter_langs' => array_values($locales),
152152
'filter_filenames' => array_map([$this, 'getLokaliseFilenameFromDomain'], $domains),
153153
'export_empty_as' => 'skip',
154+
'replace_breaks' => false,
154155
],
155156
]);
156157

src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ public function testReadForOneLocaleAndOneDomain(string $locale, string $domain,
562562
'filter_langs' => [$locale],
563563
'filter_filenames' => [$domain.'.xliff'],
564564
'export_empty_as' => 'skip',
565+
'replace_breaks' => false,
565566
]);
566567

567568
$this->assertSame('POST', $method);

0 commit comments

Comments
 (0)