8000 Merge branch '2.7' into 2.8 · symfony/symfony@8d53763 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d53763

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Fix max width for multibyte keys in choice question [Console] Display console application name even when no version set Remove empty statements.
2 parents 26979ed + 5c29e71 commit 8d53763

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/DependencyInjection/FormLoginExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\DependencyInjection\Reference;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Extension\Extension;;
16+
use Symfony\Component\DependencyInjection\Extension\Extension;
1717

1818
class FormLoginExtension extends Extension
1919
{

src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection;
1313

14-
use Symfony\Component\DependencyInjection\Extension\Extension;;
14+
use Symfony\Component\DependencyInjection\Extension\Extension;
1515
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\Config\FileLocator;

src/Symfony/Component/Console/Application.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,12 @@ public function setVersion($version)
312312
*/
313313
public function getLongVersion()
314314
{
315-
if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) {
316-
return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
315+
if ('UNKNOWN' !== $this->getName()) {
316+
if ('UNKNOWN' !== $this->getVersion()) {
317+
return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
318+
}
319+
320+
return sprintf('<info>%s</info>', $this->getName());
317321
}
318322

319323
return '<info>Console Tool</info>';

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ protected function writePrompt(OutputInterface $output, Question $question)
160160
$message = $question->getQuestion();
161161

162162
if ($question instanceof ChoiceQuestion) {
163-
$width = max(array_map('strlen', array_keys($question->getChoices())));
163+
$maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
164164

165165
$messages = (array) $question->getQuestion();
166166
foreach ($question->getChoices() as $key => $value) {
167-
$messages[] = sprintf(" [<info>%-${width}s</info>] %s", $key, $value);
167+
$width = $maxWidth - $this->strlen($key);
168+
$messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
168169
}
169170

170171
$output->writeln($messages);

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Lines changed: 29 additions & 0 deletions
< 57AE td data-grid-cell-id="diff-6f7a4bb69ab48b28d9ef00c78f52e33072ee3a6009dde558009a9d25ea0ed8e2-352-359-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Console\Tests\Helper;
1313

14+
use Symfony\Component\Console\Formatter\OutputFormatter;
1415
use Symfony\Component\Console\Helper\QuestionHelper;
1516
use Symfony\Component\Console\Helper\HelperSet;
1617
use Symfony\Component\Console\Helper\FormatterHelper;
@@ -350,6 +351,34 @@ public function testNoInteraction()
350351
$this->assertEquals('not yet', $dialog->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question));
351352
}
352353

354+
public function testChoiceOutputFormattingQuestionForUtf8Keys()
355+
{
356+
$question = 'Lorem ipsum?';
357+
$possibleChoices = array(
358+
'foo' => 'foo',
359+
'żółw' => 'bar',
360+
'łabądź' => 'baz',
361+
);
362+
$outputShown = array(
363+
$question,
364+
' [<info>foo </info>] foo',
365+
' [<info>żółw </info>] bar',
366+
' [<info>łabądź</info>] baz',
367+
);
368+
$output = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
369+
$output->method('getFormatter')->willReturn(new OutputFormatter());
370+
371+
$dialog = new QuestionHelper();
372+
$dialog->setInputStream($this->getInputStream("\n"));
373+
$helperSet = new HelperSet(array(new FormatterHelper()));
374+
$dialog->setHelperSet($helperSet);
375+
376+
$output->expects($this->once())->method('writeln')->with($this->equalTo($outputShown));
377+
378+
$question = new ChoiceQuestion($question, $possibleChoices, 'foo');
379+
$dialog->ask($this->createInputInterfaceMock(), $output, $question);
380+
}
381+
353382
protected function getInputStream($input)
354383
{
355384
$stream = fopen('php://memory', 'r+', false);

src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function isFile()
5252
{
5353
if (null === $this->type) {
5454
return false !== strpos($this->getFilename(), 'file');
55-
};
55+
}
5656

5757
return self::TYPE_FILE === $this->type;
5858
}

0 commit comments

Comments
 (0)
0