Merge branch '4.4' into 5.2

* 4.4:
  Fix intersection types on tests
  [Console] fix table setHeaderTitle without headers
This commit is contained in:
Nicolas Grekas 2021-07-21 13:53:35 +02:00
commit 3d8feb86ed
7 changed files with 35 additions and 12 deletions

View File

@ -167,7 +167,7 @@ class AnnotationsCacheWarmerTest extends TestCase
} }
/** /**
* @return MockObject|Reader * @return MockObject&Reader
*/ */
private function getReadOnlyReader(): object private function getReadOnlyReader(): object
{ {

View File

@ -84,7 +84,7 @@ class CachePoolDeleteCommandTest extends TestCase
} }
/** /**
* @return MockObject|KernelInterface * @return MockObject&KernelInterface
*/ */
private function getKernel(): object private function getKernel(): object
{ {

View File

@ -51,7 +51,7 @@ class CachePruneCommandTest extends TestCase
} }
/** /**
* @return MockObject|KernelInterface * @return MockObject&KernelInterface
*/ */
private function getKernel(): object private function getKernel(): object
{ {
@ -72,7 +72,7 @@ class CachePruneCommandTest extends TestCase
} }
/** /**
* @return MockObject|PruneableInterface * @return MockObject&PruneableInterface
*/ */
private function getPruneableInterfaceMock(): object private function getPruneableInterfaceMock(): object
{ {

View File

@ -218,7 +218,7 @@ class TagAwareAdapterTest extends AdapterTestCase
} }
/** /**
* @return MockObject|PruneableCacheInterface * @return MockObject&PruneableCacheInterface
*/ */
private function getPruneableMock(): AdapterInterface private function getPruneableMock(): AdapterInterface
{ {

View File

@ -362,6 +362,7 @@ class Table
$isHeader = !$this->horizontal; $isHeader = !$this->horizontal;
$isFirstRow = $this->horizontal; $isFirstRow = $this->horizontal;
$hasTitle = (bool) $this->headerTitle;
foreach ($rows as $row) { foreach ($rows as $row) {
if ($divider === $row) { if ($divider === $row) {
$isHeader = false; $isHeader = false;
@ -379,12 +380,13 @@ class Table
} }
if ($isHeader || $isFirstRow) { if ($isHeader || $isFirstRow) {
if ($isFirstRow) { $this->renderRowSeparator(
$this->renderRowSeparator(self::SEPARATOR_TOP_BOTTOM); $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
$isFirstRow = false; $hasTitle ? $this->headerTitle : null,
} else { $hasTitle ? $this->style->getHeaderTitleFormat() : null
$this->renderRowSeparator(self::SEPARATOR_TOP, $this->headerTitle, $this->style->getHeaderTitleFormat()); );
} $isFirstRow = false;
$hasTitle = false;
} }
if ($this->horizontal) { if ($this->horizontal) {
$this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat()); $this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat());

View File

@ -1322,6 +1322,27 @@ TABLE
]; ];
} }
public function testSetTitleWithoutHeaders()
{
(new Table($output = $this->getOutputStream()))
->setHeaderTitle('Reproducer')
->setRows([
['Value', '123-456'],
['Some other value', '789-0'],
])
->render();
$expected = <<<'TABLE'
+-------- Reproducer --------+
| Value | 123-456 |
| Some other value | 789-0 |
+------------------+---------+
TABLE;
$this->assertSame($expected, $this->getOutputContent($output));
}
public function testColumnMaxWidths() public function testColumnMaxWidths()
{ {
$table = new Table($output = $this->getOutputStream()); $table = new Table($output = $this->getOutputStream());

View File

@ -860,7 +860,7 @@ XML;
} }
/** /**
* @return MockObject|NormalizerInterface * @return MockObject&NormalizerInterface
*/ */
private function createMockDateTimeNormalizer(): object private function createMockDateTimeNormalizer(): object
{ {