Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ccc7fe8

Browse filesBrowse files
committed
Fixed table
1 parent e225de7 commit ccc7fe8
Copy full SHA for ccc7fe8

File tree

5 files changed

+34
-15
lines changed
Filter options

5 files changed

+34
-15
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/Helper.php
+20-1Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ public function getHelperSet()
4242
/**
4343
* Returns the length of a string, using mb_strwidth if it is available.
4444
*
45+
* @deprecated since 5.2
46+
*
4547
* @return int The length of the string
4648
*/
4749
public static function strlen(?string $string)
4850
{
49-
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::strwidth() or Helper::strlength() instead.', __METHOD__);
51+
trigger_deprecation('symfony/console', '5.2', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::strwidth() or Helper::strlength() instead.', __METHOD__);
5052

5153
return self::strwidth($string);
5254
}
@@ -155,7 +157,17 @@ public static function formatMemory(int $memory)
155157
return sprintf('%d B', $memory);
156158
}
157159

160+
/**
161+
* @deprecated since 5.2
162+
*/
158163
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
164+
{
165+
trigger_deprecation('symfony/console', '5.2', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::strwidthWithoutDecoration() or Helper::strlengthWithoutDecoration() instead.', __METHOD__);
166+
167+
return self::strwidthWithoutDecoration($formatter, $string);
168+
}
169+
170+
public static function strwidthWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
159171
{
160172
$string = self::removeDecoration($formatter, $string);
161173

@@ -166,6 +178,13 @@ public static function strlenWithoutDecoration(OutputFormatterInterface $formatt
166178
return self::strwidth($string);
167179
}
168180

181+
public static function strlengthWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
182+
{
183+
$string = self::removeDecoration($formatter, $string);
184+
185+
return self::strlength($string);
186+
}
187+
169188
public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
170189
{
171190
$isDecorated = $formatter->isDecorated();

‎src/Symfony/Component/Console/Helper/ProgressBar.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressBar.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ private function overwrite(string $message): void
475475
$messageLines = explode("\n", $message);
476476
$lineCount = \count($messageLines);
477477
foreach ($messageLines as $messageLine) {
478-
$messageLineLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $messageLine);
478+
$messageLineLength = Helper::strwidthWithoutDecoration($this->output->getFormatter(), $messageLine);
479479
if ($messageLineLength > $this->terminal->getWidth()) {
480480
$lineCount += floor($messageLineLength / $this->terminal->getWidth());
481481
}
@@ -523,7 +523,7 @@ private static function initPlaceholderFormatters(): array
523523
$completeBars = $bar->getBarOffset();
524524
$display = str_repeat($bar->getBarCharacter(), $completeBars);
525525
if ($completeBars < $bar->getBarWidth()) {
526-
$emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
526+
$emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlengthWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
527527
$display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
528528
}
529529

@@ -600,7 +600,7 @@ private function buildLine(): string
600600

601601
// gets string length for each sub line with multiline format
602602
$linesLength = array_map(function ($subLine) {
603-
return Helper::strlenWithoutDecoration($this->output->getFormatter(), rtrim($subLine, "\r"));
603+
return Helper::strwidthWithoutDecoration($this->output->getFormatter(), rtrim($subLine, "\r"));
604604
}, explode("\n", $line));
605605

606606
$linesWidth = max($linesLength);

‎src/Symfony/Component/Console/Helper/Table.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/Table.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,11 @@ private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $tit
434434
}
435435

436436
if (null !== $title) {
437-
$titleLength = Helper::strlenWithoutDecoration($formatter = $this->output->getFormatter(), $formattedTitle = sprintf($titleFormat, $title));
437+
$titleLength = Helper::strwidthWithoutDecoration($formatter = $this->output->getFormatter(), $formattedTitle = sprintf($titleFormat, $title));
438438
$markupLength = Helper::strwidth($markup);
439439
if ($titleLength > $limit = $markupLength - 4) {
440440
$titleLength = $limit;
441-
$formatLength = Helper::strlenWithoutDecoration($formatter, sprintf($titleFormat, ''));
441+
$formatLength = Helper::strwidthWithoutDecoration($formatter, sprintf($titleFormat, ''));
442442
$formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...');
443443
}
444444

@@ -511,7 +511,7 @@ private function renderCell(array $row, int $column, string $cellFormat): string
511511
return sprintf($style->getBorderFormat(), str_repeat($style->getBorderChars()[2], $width));
512512
}
513513

514-
$width += Helper::strwidth($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
514+
$width += Helper::strlength($cell) - Helper::strlengthWithoutDecoration($this->output->getFormatter(), $cell);
515515
$content = sprintf($style->getCellRowContentFormat(), $cell);
516516

517517
$padType = $style->getPadType();
@@ -569,7 +569,7 @@ private function buildTableRows(array $rows): TableRows
569569
foreach ($rows[$rowKey] as $column => $cell) {
570570
$colspan = $cell instanceof TableCell ? $cell->getColspan() : 1;
571571

572-
if (isset($this->columnMaxWidths[$column]) && Helper::strlenWithoutDecoration($formatter, $cell) > $this->columnMaxWidths[$column]) {
572+
if (isset($this->columnMaxWidths[$column]) && Helper::strwidthWithoutDecoration($formatter, $cell) > $this->columnMaxWidths[$column]) {
573573
$cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan);
574574
}
575575
if (!strstr($cell, "\n")) {
@@ -783,7 +783,7 @@ private function getCellWidth(array $row, int $column): int
783783

784784
if (isset($row[$column])) {
785785
$cell = $row[$column];
786-
$cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
786+
$cellWidth = Helper::strwidthWithoutDecoration($this->output->getFormatter(), $cell);
787787
}
788788

789789
$columnWidth = $this->columnWidths[$column] ?? 0;

‎src/Symfony/Component/Console/Output/ConsoleSectionOutput.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Output/ConsoleSectionOutput.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFr
138138

139139
private function getDisplayLength(string $text): string
140140
{
141-
return Helper::strlenWithoutDecoration($this->getFormatter(), str_replace("\t", ' ', $text));
141+
return Helper::strwidthWithoutDecoration($this->getFormatter(), str_replace("\t", ' ', $text));
142142
}
143143
}

‎src/Symfony/Component/Console/Style/SymfonyStyle.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Style/SymfonyStyle.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function title(string $message)
7676
$this->autoPrependBlock();
7777
$this->writeln([
7878
sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
79-
sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
79+
sprintf('<comment>%s</>', str_repeat('=', Helper::strwidthWithoutDecoration($this->getFormatter(), $message))),
8080
]);
8181
$this->newLine();
8282
}
@@ -89,7 +89,7 @@ public function section(string $message)
8989
$this->autoPrependBlock();
9090
$this->writeln([
9191
sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
92-
sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
92+
sprintf('<comment>%s</>', str_repeat('-', Helper::strwidthWithoutDecoration($this->getFormatter(), $message))),
9393
]);
9494
$this->newLine();
9595
}
@@ -461,7 +461,7 @@ private function writeBuffer(string $message, bool $newLine, int $type): void
461461
private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array
462462
{
463463
$indentLength = 0;
464-
$prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
464+
$prefixLength = Helper::strwidthWithoutDecoration($this->getFormatter(), $prefix);
465465
$lines = [];
466466

467467
if (null !== $type) {
@@ -476,7 +476,7 @@ private function createBlock(iterable $messages, string $type = null, string $st
476476
$message = OutputFormatter::escape($message);
477477
}
478478

479-
$decorationLength = Helper::strwidth($message) - Helper::strlenWithoutDecoration($this->getFormatter(), $message);
479+
$decorationLength = Helper::strwidth($message) - Helper::strwidthWithoutDecoration($this->getFormatter(), $message);
480480
$messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength);
481481
$messageLines = explode(\PHP_EOL, wordwrap($message, $messageLineLength, \PHP_EOL, true));
482482
foreach ($messageLines as $messageLine) {
@@ -501,7 +501,7 @@ private function createBlock(iterable $messages, string $type = null, string $st
501501
}
502502

503503
$line = $prefix.$line;
504-
$line .= str_repeat(' ', max($this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line), 0));
504+
$line .= str_repeat(' ', max($this->lineLength - Helper::strwidthWithoutDecoration($this->getFormatter(), $line), 0));
505505

506506
if ($style) {
507507
$line = sprintf('<%s>%s</>', $style, $line);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.