Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf7ba71d

Browse files
bug#21438 [Console] Fix TableCell issues with decoration (ogizanagi)
This PR was merged into the 2.7 branch.Discussion----------[Console] Fix TableCell issues with decoration| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes (failure unrelated)| Fixed tickets |#21434| License | MIT| Doc PR | N/ACommits-------50373f3 [Console] Fix TableCell issues with decoration
2 parents536e073 +50373f3 commitf7ba71d

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ private function getColumnWidth($column)
518518

519519
foreach ($rowas$i =>$cell) {
520520
if ($cellinstanceof TableCell) {
521-
$textLength =strlen($cell);
521+
$textLength =Helper::strlenWithoutDecoration($this->output->getFormatter(),$cell);
522522
if ($textLength >0) {
523523
$contentColumns =str_split($cell,ceil($textLength /$cell->getColspan()));
524524
foreach ($contentColumnsas$position =>$content) {

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

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ protected function tearDown()
3535
/**
3636
* @dataProvider testRenderProvider
3737
*/
38-
publicfunctiontestRender($headers,$rows,$style,$expected)
38+
publicfunctiontestRender($headers,$rows,$style,$expected,$decorated =false)
3939
{
40-
$table =newTable($output =$this->getOutputStream());
40+
$table =newTable($output =$this->getOutputStream($decorated));
4141
$table
4242
->setHeaders($headers)
4343
->setRows($rows)
@@ -51,9 +51,9 @@ public function testRender($headers, $rows, $style, $expected)
5151
/**
5252
* @dataProvider testRenderProvider
5353
*/
54-
publicfunctiontestRenderAddRows($headers,$rows,$style,$expected)
54+
publicfunctiontestRenderAddRows($headers,$rows,$style,$expected,$decorated =false)
5555
{
56-
$table =newTable($output =$this->getOutputStream());
56+
$table =newTable($output =$this->getOutputStream($decorated));
5757
$table
5858
->setHeaders($headers)
5959
->addRows($rows)
@@ -67,9 +67,9 @@ public function testRenderAddRows($headers, $rows, $style, $expected)
6767
/**
6868
* @dataProvider testRenderProvider
6969
*/
70-
publicfunctiontestRenderAddRowsOneByOne($headers,$rows,$style,$expected)
70+
publicfunctiontestRenderAddRowsOneByOne($headers,$rows,$style,$expected,$decorated =false)
7171
{
72-
$table =newTable($output =$this->getOutputStream());
72+
$table =newTable($output =$this->getOutputStream($decorated));
7373
$table
7474
->setHeaders($headers)
7575
->setStyle($style)
@@ -485,6 +485,35 @@ public function testRenderProvider()
485485

486486
TABLE
487487
),
488+
'Coslpan and table cells with comment style' =>array(
489+
array(
490+
newTableCell('<comment>Long Title</comment>',array('colspan' =>3)),
491+
),
492+
array(
493+
array(
494+
newTableCell('9971-5-0210-0',array('colspan' =>3)),
495+
),
496+
newTableSeparator(),
497+
array(
498+
'Dante Alighieri',
499+
'J. R. R. Tolkien',
500+
'J. R. R',
501+
),
502+
),
503+
'default',
504+
<<<TABLE
505+
+-----------------+------------------+---------+
506+
|\033[32m\033[39m\033[33mLong Title\033[39m\033[32m\033[39m|
507+
+-----------------+------------------+---------+
508+
| 9971-5-0210-0 |
509+
+-----------------+------------------+---------+
510+
| Dante Alighieri | J. R. R. Tolkien | J. R. R |
511+
+-----------------+------------------+---------+
512+
513+
TABLE
514+
,
515+
true,
516+
),
488517
);
489518
}
490519

@@ -596,9 +625,9 @@ public function testGetStyleDefinition()
596625
Table::getStyleDefinition('absent');
597626
}
598627

599-
protectedfunctiongetOutputStream()
628+
protectedfunctiongetOutputStream($decorated =false)
600629
{
601-
returnnewStreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL,false);
630+
returnnewStreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL,$decorated);
602631
}
603632

604633
protectedfunctiongetOutputContent(StreamOutput$output)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp