Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #35676 [Console] Handle zero row count in appendRow() for Table (…
…Adam Prickett) This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [Console] Handle zero row count in appendRow() for Table | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a When a `Table` is created and rendered with no rows (headers only) and subsequently rows are added using `appendRow()`, the first call to `appendRow()` clears back one line too far., thus removing the last run This is caused by `calculateRowCount()` not accounting for the fact that the footer separator is also the header separator when no rows are present. This PR works around the issue by checking to ensure that at least 1 row exists before including the footer separator in the row count. ## Example Command: ```php <?php namespace App\Command; class TableTestCommand extends Command { // ... protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('My table'); $table = new Table($output->section()); $table->setHeaders(['Column', 'Another column']); $table->render(); $table->appendRow(['Value', 'Another Value']); $table->appendRow(['Value', 'Another Value']); } } ``` Before fix: ``` +--------+----------------+ | Column | Another column | +--------+----------------+ | Value | Another Value | | Value | Another Value | +--------+----------------+ ``` After fix: ``` My table +--------+----------------+ | Column | Another column | +--------+----------------+ | Value | Another Value | | Value | Another Value | +--------+----------------+ ``` Commits ------- 9b38259 [Console] Handle zero row count in appendRow() for Table
- Loading branch information