| 1 | <?php |
||
| 12 | class ConsoleTableWriter implements Writer |
||
| 13 | { |
||
| 14 | use WriterTemplate; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var OutputInterface |
||
| 18 | */ |
||
| 19 | private $output; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var Table |
||
| 23 | */ |
||
| 24 | private $table; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var array |
||
| 28 | */ |
||
| 29 | private $firstItem; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param OutputInterface $output |
||
| 33 | * @param Table $table |
||
| 34 | */ |
||
| 35 | 1 | public function __construct(OutputInterface $output, Table $table) { |
|
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | */ |
||
| 43 | 1 | public function writeItem(array $item) { |
|
| 44 | |||
| 45 | // Save first item to get keys to display at header |
||
| 46 | 1 | if (is_null($this->firstItem)) { |
|
| 47 | 1 | $this->firstItem = $item; |
|
| 48 | 1 | } |
|
| 49 | |||
| 50 | 1 | $this->table->addRow($item); |
|
| 51 | 1 | } |
|
| 52 | |||
| 53 | /** |
||
| 54 | * {@inheritdoc} |
||
| 55 | */ |
||
| 56 | 1 | public function finish() { |
|
| 57 | 1 | $this->table->setHeaders(array_keys($this->firstItem)); |
|
| 58 | 1 | $this->table->render(); |
|
| 59 | |||
| 60 | 1 | $this->firstItem = null; |
|
|
|
|||
| 61 | 1 | } |
|
| 62 | |||
| 63 | /** |
||
| 64 | * @return Table |
||
| 65 | */ |
||
| 66 | public function getTable() |
||
| 70 | } |
||
| 71 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..