platform/api/symfony/Component/Console/Helper/Table.yaml

359 lines
11 KiB
YAML
Raw Normal View History

2024-09-02 17:44:11 +00:00
name: Table
class_comment: "# * Provides helpers to display a table.\n# *\n# * @author Fabien\
\ Potencier <fabien@symfony.com>\n# * @author \u0421\u0430\u0448\u0430 \u0421\u0442\
\u0430\u043C\u0435\u043D\u043A\u043E\u0432\u0438\u045B <umpirsky@gmail.com>\n# *\
\ @author Abdellatif Ait boudad <a.aitboudad@gmail.com>\n# * @author Max Grigorian\
\ <maxakawizard@gmail.com>\n# * @author Dany Maillard <danymaillard93b@gmail.com>"
dependencies:
- name: InvalidArgumentException
type: class
source: Symfony\Component\Console\Exception\InvalidArgumentException
- name: RuntimeException
type: class
source: Symfony\Component\Console\Exception\RuntimeException
- name: OutputFormatter
type: class
source: Symfony\Component\Console\Formatter\OutputFormatter
- name: WrappableOutputFormatterInterface
type: class
source: Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface
- name: ConsoleSectionOutput
type: class
source: Symfony\Component\Console\Output\ConsoleSectionOutput
- name: OutputInterface
type: class
source: Symfony\Component\Console\Output\OutputInterface
properties: []
methods:
- name: setStyleDefinition
visibility: public
parameters:
- name: name
- name: style
comment: "# * Provides helpers to display a table.\n# *\n# * @author Fabien Potencier\
\ <fabien@symfony.com>\n# * @author \u0421\u0430\u0448\u0430 \u0421\u0442\u0430\
\u043C\u0435\u043D\u043A\u043E\u0432\u0438\u045B <umpirsky@gmail.com>\n# * @author\
\ Abdellatif Ait boudad <a.aitboudad@gmail.com>\n# * @author Max Grigorian <maxakawizard@gmail.com>\n\
# * @author Dany Maillard <danymaillard93b@gmail.com>\n# */\n# class Table\n#\
\ {\n# private const SEPARATOR_TOP = 0;\n# private const SEPARATOR_TOP_BOTTOM\
\ = 1;\n# private const SEPARATOR_MID = 2;\n# private const SEPARATOR_BOTTOM =\
\ 3;\n# private const BORDER_OUTSIDE = 0;\n# private const BORDER_INSIDE = 1;\n\
# private const DISPLAY_ORIENTATION_DEFAULT = 'default';\n# private const DISPLAY_ORIENTATION_HORIZONTAL\
\ = 'horizontal';\n# private const DISPLAY_ORIENTATION_VERTICAL = 'vertical';\n\
# \n# private ?string $headerTitle = null;\n# private ?string $footerTitle = null;\n\
# private array $headers = [];\n# private array $rows = [];\n# private array $effectiveColumnWidths\
\ = [];\n# private int $numberOfColumns;\n# private TableStyle $style;\n# private\
\ array $columnStyles = [];\n# private array $columnWidths = [];\n# private array\
\ $columnMaxWidths = [];\n# private bool $rendered = false;\n# private string\
\ $displayOrientation = self::DISPLAY_ORIENTATION_DEFAULT;\n# \n# private static\
\ array $styles;\n# \n# public function __construct(\n# private OutputInterface\
\ $output,\n# ) {\n# self::$styles ??= self::initStyles();\n# \n# $this->setStyle('default');\n\
# }\n# \n# /**\n# * Sets a style definition."
- name: getStyleDefinition
visibility: public
parameters:
- name: name
comment: '# * Gets a style definition by name.'
- name: setStyle
visibility: public
parameters:
- name: name
comment: '# * Sets table style.
# *
# * @return $this'
- name: getStyle
visibility: public
parameters: []
comment: '# * Gets the current table style.'
- name: setColumnStyle
visibility: public
parameters:
- name: columnIndex
- name: name
comment: '# * Sets table column style.
# *
# * @param TableStyle|string $name The style name or a TableStyle instance
# *
# * @return $this'
- name: getColumnStyle
visibility: public
parameters:
- name: columnIndex
comment: '# * Gets the current style for a column.
# *
# * If style was not set, it returns the global table style.'
- name: setColumnWidth
visibility: public
parameters:
- name: columnIndex
- name: width
comment: '# * Sets the minimum width of a column.
# *
# * @return $this'
- name: setColumnWidths
visibility: public
parameters:
- name: widths
comment: '# * Sets the minimum width of all columns.
# *
# * @return $this'
- name: setColumnMaxWidth
visibility: public
parameters:
- name: columnIndex
- name: width
comment: '# * Sets the maximum width of a column.
# *
# * Any cell within this column which contents exceeds the specified width will
be wrapped into multiple lines, while
# * formatted strings are preserved.
# *
# * @return $this'
- name: setHeaders
visibility: public
parameters:
- name: headers
comment: '# * @return $this'
- name: setRows
visibility: public
parameters:
- name: rows
comment: '# * @return $this'
- name: addRows
visibility: public
parameters:
- name: rows
comment: '# * @return $this'
- name: addRow
visibility: public
parameters:
- name: row
comment: '# * @return $this'
- name: appendRow
visibility: public
parameters:
- name: row
comment: '# * Adds a row to the table, and re-renders the table.
# *
# * @return $this'
- name: setRow
visibility: public
parameters:
- name: column
- name: row
comment: '# * @return $this'
- name: setHeaderTitle
visibility: public
parameters:
- name: title
comment: '# * @return $this'
- name: setFooterTitle
visibility: public
parameters:
- name: title
comment: '# * @return $this'
- name: setHorizontal
visibility: public
parameters:
- name: horizontal
default: 'true'
comment: '# * @return $this'
- name: setVertical
visibility: public
parameters:
- name: vertical
default: 'true'
comment: '# * @return $this'
- name: render
visibility: public
parameters: []
comment: '# * Renders table to output.
# *
# * Example:
# *
# * +---------------+-----------------------+------------------+
# * | ISBN | Title | Author |
# * +---------------+-----------------------+------------------+
# * | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
# * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
# * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
# * +---------------+-----------------------+------------------+'
- name: renderRowSeparator
visibility: private
parameters:
- name: type
default: self::SEPARATOR_MID
- name: title
default: 'null'
- name: titleFormat
default: 'null'
comment: '# * Renders horizontal header separator.
# *
# * Example:
# *
# * +-----+-----------+-------+'
- name: renderColumnSeparator
visibility: private
parameters:
- name: type
default: self::BORDER_OUTSIDE
comment: '# * Renders vertical column separator.'
- name: renderRow
visibility: private
parameters:
- name: row
- name: cellFormat
- name: firstCellFormat
default: 'null'
comment: '# * Renders table row.
# *
# * Example:
# *
# * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |'
- name: renderCell
visibility: private
parameters:
- name: row
- name: column
- name: cellFormat
comment: '# * Renders table cell with padding.'
- name: calculateNumberOfColumns
visibility: private
parameters:
- name: rows
comment: '# * Calculate number of columns for this table.'
- name: buildTableRows
visibility: private
parameters:
- name: rows
comment: null
- name: fillNextRows
visibility: private
parameters:
- name: rows
- name: line
comment: "# @var WrappableOutputFormatterInterface $formatter */\n# $formatter =\
\ $this->output->getFormatter();\n# $unmergedRows = [];\n# for ($rowKey = 0; $rowKey\
\ < \\count($rows); ++$rowKey) {\n# $rows = $this->fillNextRows($rows, $rowKey);\n\
# \n# // Remove any new line breaks and replace it with a new line\n# foreach\
\ ($rows[$rowKey] as $column => $cell) {\n# $colspan = $cell instanceof TableCell\
\ ? $cell->getColspan() : 1;\n# \n# if (isset($this->columnMaxWidths[$column])\
\ && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column])\
\ {\n# $cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column]\
\ * $colspan);\n# }\n# if (!str_contains($cell ?? '', \"\\n\")) {\n# continue;\n\
# }\n# $eol = str_contains($cell ?? '', \"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n\
# $escaped = implode($eol, array_map(OutputFormatter::escapeTrailingBackslash(...),\
\ explode($eol, $cell)));\n# $cell = $cell instanceof TableCell ? new TableCell($escaped,\
\ ['colspan' => $cell->getColspan()]) : $escaped;\n# $lines = explode($eol, str_replace($eol,\
\ '<fg=default;bg=default></>'.$eol, $cell));\n# foreach ($lines as $lineKey =>\
\ $line) {\n# if ($colspan > 1) {\n# $line = new TableCell($line, ['colspan' =>\
\ $colspan]);\n# }\n# if (0 === $lineKey) {\n# $rows[$rowKey][$column] = $line;\n\
# } else {\n# if (!\\array_key_exists($rowKey, $unmergedRows) || !\\array_key_exists($lineKey,\
\ $unmergedRows[$rowKey])) {\n# $unmergedRows[$rowKey][$lineKey] = $this->copyRow($rows,\
\ $rowKey);\n# }\n# $unmergedRows[$rowKey][$lineKey][$column] = $line;\n# }\n\
# }\n# }\n# }\n# \n# return new TableRows(function () use ($rows, $unmergedRows):\
\ \\Traversable {\n# foreach ($rows as $rowKey => $row) {\n# $rowGroup = [$row\
\ instanceof TableSeparator ? $row : $this->fillCells($row)];\n# \n# if (isset($unmergedRows[$rowKey]))\
\ {\n# foreach ($unmergedRows[$rowKey] as $row) {\n# $rowGroup[] = $row instanceof\
\ TableSeparator ? $row : $this->fillCells($row);\n# }\n# }\n# yield $rowGroup;\n\
# }\n# });\n# }\n# \n# private function calculateRowCount(): int\n# {\n# $numberOfRows\
\ = \\count(iterator_to_array($this->buildTableRows(array_merge($this->headers,\
\ [new TableSeparator()], $this->rows))));\n# \n# if ($this->headers) {\n# ++$numberOfRows;\
\ // Add row for header separator\n# }\n# \n# if ($this->rows) {\n# ++$numberOfRows;\
\ // Add row for footer separator\n# }\n# \n# return $numberOfRows;\n# }\n# \n\
# /**\n# * fill rows that contains rowspan > 1.\n# *\n# * @throws InvalidArgumentException"
- name: fillCells
visibility: private
parameters:
- name: row
comment: '# * fill cells for a row that contains colspan > 1.'
- name: copyRow
visibility: private
parameters:
- name: rows
- name: line
comment: null
- name: getNumberOfColumns
visibility: private
parameters:
- name: row
comment: '# * Gets number of columns by row.'
- name: getRowColumns
visibility: private
parameters:
- name: row
comment: '# * Gets list of columns for the given row.'
- name: calculateColumnsWidth
visibility: private
parameters:
- name: groups
comment: '# * Calculates columns widths.'
- name: getColumnSeparatorWidth
visibility: private
parameters: []
comment: null
- name: getCellWidth
visibility: private
parameters:
- name: row
- name: column
comment: null
- name: cleanup
visibility: private
parameters: []
comment: '# * Called after rendering to cleanup cache data.'
- name: initStyles
visibility: private
parameters: []
comment: '# * @return array<string, TableStyle>'
- name: resolveStyle
visibility: private
parameters:
- name: name
comment: null
traits:
- Symfony\Component\Console\Exception\InvalidArgumentException
- Symfony\Component\Console\Exception\RuntimeException
- Symfony\Component\Console\Formatter\OutputFormatter
- Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface
- Symfony\Component\Console\Output\ConsoleSectionOutput
- Symfony\Component\Console\Output\OutputInterface
interfaces: []