Symfony console helper to create a table

Code
<?php

use Symfony\Component\Console\Helper\Table;
use 
Symfony\Component\Console\Output\StreamOutput;

$rows = [
    [
        
'col1' => 1,
        
'col2' => 'foo',
        
'col3' => 'first',
    ],
    [
        
'col1' => 2,
        
'col2' => 'bar',
        
'col3' => 'second',
    ],
    [
        
'col1' => 3,
        
'col2' => 'baz',
        
'col3' => 'third',
    ],
];

$stream fopen('php://output''w');
$output = new StreamOutput($stream);

$table = new Table($output);
$table->setHeaders(array_keys($rows[0]));
$table->addRows($rows);

echo 
'<pre>';
$table->render();
echo 
'</pre>';
Result
+------+------+--------+
| col1 | col2 | col3   |
+------+------+--------+
| 1    | foo  | first  |
| 2    | bar  | second |
| 3    | baz  | third  |
+------+------+--------+
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6