function SymfonyStyle::definitionList
Formats a list of key/value horizontally.
Each row can be one of:
- 'A title'
- ['key' => 'value']
- new TableSeparator()
File
-
vendor/
symfony/ console/ Style/ SymfonyStyle.php, line 186
Class
- SymfonyStyle
- Output decorator helpers for the Symfony Style Guide.
Namespace
Symfony\Component\Console\StyleCode
public function definitionList(string|array|TableSeparator ...$list) : void {
$headers = [];
$row = [];
foreach ($list as $value) {
if ($value instanceof TableSeparator) {
$headers[] = $value;
$row[] = $value;
continue;
}
if (\is_string($value)) {
$headers[] = new TableCell($value, [
'colspan' => 2,
]);
$row[] = null;
continue;
}
if (!\is_array($value)) {
throw new InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.');
}
$headers[] = key($value);
$row[] = current($value);
}
$this->horizontalTable($headers, [
$row,
]);
}