Analysers reports used the Symfony 2.5 Console Table Component

Data and render were separated on each analyser reports.

While in previous verson 3.x, I’ve introduced a forked
[https://github.com/llaville/php-compat-info/blob/v3/src/Bartlett/CompatInfo/ConsoleHelper.php]
of Symfony Console TableHelper (with footer support), today CompatInfo 3.2 will used the new Symfony 2.5 Console Table Helper.

As mentionned by Symfony Team, the Table Helper was deprecated in Symfony 2.5 and will be removed in Symfony 3.0.

We have two challenges to solve here :

  • introduces again the footer behavior

  • let each analyser choose to render results

For the first challenge, here are the code used to simulate a footer.

<?php

use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableSeparator;

$table = new Table($output);
$table
    ->setHeaders(array('ISBN', 'Title', 'Author'))
    ->setRows(array(
        array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
        array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
        array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'),
        array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
        new TableSeparator(),
        array('<info>Footer col.1</info>','<info>Footer col.2</info>','<info>Footer col.3</info>'),
    ))
;
$table->render();

that will render something like :

default style
changes the default style to compact
<?php
    $table->setStyle('compact');

that will render something like :

compact style
changes the default style to borderless
<?php
    $table->setStyle('borderless');

that will render something like :

borderless style
Published by Laurent Laville on 2014-07-08