code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
public function setOverwrite(bool $overwrite) : void { $this->overwrite = $overwrite; }
Sets whether to overwrite the progressbar, false for new line.
setOverwrite
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressBar.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressBar.php
MIT
public function clear() : void { if (!$this->overwrite) { return; } if (null === $this->format) { $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat()); } $this->overwrite(''); }
Removes the progress bar from the current line. This is useful if you wish to write some output while a progress bar is running. Call display() to show the progress bar again.
clear
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressBar.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressBar.php
MIT
private function overwrite(string $message) : void { if ($this->previousMessage === $message) { return; } $originalMessage = $message; if ($this->overwrite) { if (null !== $this->previousMessage) { if ($this->output instanceof ConsoleSectionOutput) { $messageLines = \explode("\n", $this->previousMessage); $lineCount = \count($messageLines); foreach ($messageLines as $messageLine) { $messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine)); if ($messageLineLength > $this->terminal->getWidth()) { $lineCount += \floor($messageLineLength / $this->terminal->getWidth()); } } $this->output->clear($lineCount); } else { $lineCount = \substr_count($this->previousMessage, "\n"); for ($i = 0; $i < $lineCount; ++$i) { $this->cursor->moveToColumn(1); $this->cursor->clearLine(); $this->cursor->moveUp(); } $this->cursor->moveToColumn(1); $this->cursor->clearLine(); } } } elseif ($this->step > 0) { $message = \PHP_EOL . $message; } $this->previousMessage = $originalMessage; $this->lastWriteTime = \microtime(\true); $this->output->write($message); ++$this->writeCount; }
Overwrites a previous message to the output.
overwrite
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressBar.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressBar.php
MIT
public function __construct(OutputInterface $output, ?string $format = null, int $indicatorChangeInterval = 100, ?array $indicatorValues = null) { $this->output = $output; $format ??= $this->determineBestFormat(); $indicatorValues ??= ['-', '\\', '|', '/']; $indicatorValues = \array_values($indicatorValues); if (2 > \count($indicatorValues)) { throw new InvalidArgumentException('Must have at least 2 indicator value characters.'); } $this->format = self::getFormatDefinition($format); $this->indicatorChangeInterval = $indicatorChangeInterval; $this->indicatorValues = $indicatorValues; $this->startTime = \time(); }
@param int $indicatorChangeInterval Change interval in milliseconds @param array|null $indicatorValues Animated indicator characters
__construct
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressIndicator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressIndicator.php
MIT
public function setMessage(?string $message) { $this->message = $message; $this->display(); }
Sets the current indicator message. @return void
setMessage
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressIndicator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressIndicator.php
MIT
public function start(string $message) { if ($this->started) { throw new LogicException('Progress indicator already started.'); } $this->message = $message; $this->started = \true; $this->startTime = \time(); $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval; $this->indicatorCurrent = 0; $this->display(); }
Starts the indicator output. @return void
start
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressIndicator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressIndicator.php
MIT
public function finish(string $message) { if (!$this->started) { throw new LogicException('Progress indicator has not yet been started.'); } $this->message = $message; $this->display(); $this->output->writeln(''); $this->started = \false; }
Finish the indicator with message. @return void
finish
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressIndicator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressIndicator.php
MIT
public static function getFormatDefinition(string $name) : ?string { return self::FORMATS[$name] ?? null; }
Gets the format for a given name.
getFormatDefinition
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressIndicator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressIndicator.php
MIT
public static function setPlaceholderFormatterDefinition(string $name, callable $callable) { self::$formatters ??= self::initPlaceholderFormatters(); self::$formatters[$name] = $callable; }
Sets a placeholder formatter for a given name. This method also allow you to override an existing placeholder. @return void
setPlaceholderFormatterDefinition
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressIndicator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressIndicator.php
MIT
private function overwrite(string $message) : void { if ($this->output->isDecorated()) { $this->output->write("\r\x1b[2K"); $this->output->write($message); } else { $this->output->writeln($message); } }
Overwrites a previous message to the output.
overwrite
php
deptrac/deptrac
vendor/symfony/console/Helper/ProgressIndicator.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/ProgressIndicator.php
MIT
public function ask(InputInterface $input, OutputInterface $output, Question $question) : mixed { if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } if (!$input->isInteractive()) { return $this->getDefaultAnswer($question); } if ($input instanceof StreamableInputInterface && ($stream = $input->getStream())) { $this->inputStream = $stream; } try { if (!$question->getValidator()) { return $this->doAsk($output, $question); } $interviewer = fn() => $this->doAsk($output, $question); return $this->validateAttempts($interviewer, $output, $question); } catch (MissingInputException $exception) { $input->setInteractive(\false); if (null === ($fallbackOutput = $this->getDefaultAnswer($question))) { throw $exception; } return $fallbackOutput; } }
Asks a question to the user. @return mixed The user answer @throws RuntimeException If there is no data to read in the input stream
ask
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
public static function disableStty() { self::$stty = \false; }
Prevents usage of stty. @return void
disableStty
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
private function doAsk(OutputInterface $output, Question $question) : mixed { $this->writePrompt($output, $question); $inputStream = $this->inputStream ?: \STDIN; $autocomplete = $question->getAutocompleterCallback(); if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) { $ret = \false; if ($question->isHidden()) { try { $hiddenResponse = $this->getHiddenResponse($output, $inputStream, $question->isTrimmable()); $ret = $question->isTrimmable() ? \trim($hiddenResponse) : $hiddenResponse; } catch (RuntimeException $e) { if (!$question->isHiddenFallback()) { throw $e; } } } if (\false === $ret) { $isBlocked = \stream_get_meta_data($inputStream)['blocked'] ?? \true; if (!$isBlocked) { \stream_set_blocking($inputStream, \true); } $ret = $this->readInput($inputStream, $question); if (!$isBlocked) { \stream_set_blocking($inputStream, \false); } if (\false === $ret) { throw new MissingInputException('Aborted.'); } if ($question->isTrimmable()) { $ret = \trim($ret); } } } else { $autocomplete = $this->autocomplete($output, $question, $inputStream, $autocomplete); $ret = $question->isTrimmable() ? \trim($autocomplete) : $autocomplete; } if ($output instanceof ConsoleSectionOutput) { $output->addContent(''); // add EOL to the question $output->addContent($ret); } $ret = \strlen($ret) > 0 ? $ret : $question->getDefault(); if ($normalizer = $question->getNormalizer()) { return $normalizer($ret); } return $ret; }
Asks the question to the user. @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden
doAsk
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
protected function writePrompt(OutputInterface $output, Question $question) { $message = $question->getQuestion(); if ($question instanceof ChoiceQuestion) { $output->writeln(\array_merge([$question->getQuestion()], $this->formatChoiceQuestionChoices($question, 'info'))); $message = $question->getPrompt(); } $output->write($message); }
Outputs the question prompt. @return void
writePrompt
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
protected function writeError(OutputInterface $output, \Exception $error) { if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) { $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'); } else { $message = '<error>' . $error->getMessage() . '</error>'; } $output->writeln($message); }
Outputs an error message. @return void
writeError
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
private function getHiddenResponse(OutputInterface $output, $inputStream, bool $trimmable = \true) : string { if ('\\' === \DIRECTORY_SEPARATOR) { $exe = __DIR__ . '/../Resources/bin/hiddeninput.exe'; // handle code running from a phar if (\str_starts_with(__FILE__, 'phar:')) { $tmpExe = \sys_get_temp_dir() . '/hiddeninput.exe'; \copy($exe, $tmpExe); $exe = $tmpExe; } $sExec = \shell_exec('"' . $exe . '"'); $value = $trimmable ? \rtrim($sExec) : $sExec; $output->writeln(''); if (isset($tmpExe)) { \unlink($tmpExe); } return $value; } if (self::$stty && Terminal::hasSttyAvailable()) { $sttyMode = \shell_exec('stty -g'); \shell_exec('stty -echo'); } elseif ($this->isInteractiveInput($inputStream)) { throw new RuntimeException('Unable to hide the response.'); } $value = \fgets($inputStream, 4096); if (4095 === \strlen($value)) { $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; $errOutput->warning('The value was possibly truncated by your shell or terminal emulator'); } if (self::$stty && Terminal::hasSttyAvailable()) { \shell_exec('stty ' . $sttyMode); } if (\false === $value) { throw new MissingInputException('Aborted.'); } if ($trimmable) { $value = \trim($value); } $output->writeln(''); return $value; }
Gets a hidden response from user. @param resource $inputStream The handler resource @param bool $trimmable Is the answer trimmable @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden
getHiddenResponse
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question) : mixed { $error = null; $attempts = $question->getMaxAttempts(); while (null === $attempts || $attempts--) { if (null !== $error) { $this->writeError($output, $error); } try { return $question->getValidator()($interviewer()); } catch (RuntimeException $e) { throw $e; } catch (\Exception $error) { } } throw $error; }
Validates an attempt. @param callable $interviewer A callable that will ask for a question and return the result @throws \Exception In case the max number of attempts has been reached and no valid response has been given
validateAttempts
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
private function readInput($inputStream, Question $question) : string|false { if (!$question->isMultiline()) { $cp = $this->setIOCodepage(); $ret = \fgets($inputStream, 4096); return $this->resetIOCodepage($cp, $ret); } $multiLineStreamReader = $this->cloneInputStream($inputStream); if (null === $multiLineStreamReader) { return \false; } $ret = ''; $cp = $this->setIOCodepage(); while (\false !== ($char = \fgetc($multiLineStreamReader))) { if (\PHP_EOL === "{$ret}{$char}") { break; } $ret .= $char; } return $this->resetIOCodepage($cp, $ret); }
Reads one or more lines of input and returns what is read. @param resource $inputStream The handler resource @param Question $question The question being asked
readInput
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
private function resetIOCodepage(int $cp, string|false $input) : string|false { if (0 !== $cp) { \sapi_windows_cp_set($cp); if (\false !== $input && '' !== $input) { $input = \sapi_windows_cp_conv(\sapi_windows_cp_get('oem'), $cp, $input); } } return $input; }
Sets console I/O to the specified code page and converts the user input.
resetIOCodepage
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
private function cloneInputStream($inputStream) { $streamMetaData = \stream_get_meta_data($inputStream); $seekable = $streamMetaData['seekable'] ?? \false; $mode = $streamMetaData['mode'] ?? 'rb'; $uri = $streamMetaData['uri'] ?? null; if (null === $uri) { return null; } $cloneStream = \fopen($uri, $mode); // For seekable and writable streams, add all the same data to the // cloned stream and then seek to the same offset. if (\true === $seekable && !\in_array($mode, ['r', 'rb', 'rt'])) { $offset = \ftell($inputStream); \rewind($inputStream); \stream_copy_to_stream($inputStream, $cloneStream); \fseek($inputStream, $offset); \fseek($cloneStream, $offset); } return $cloneStream; }
Clones an input stream in order to act on one instance of the same stream without affecting the other instance. @param resource $inputStream The handler resource @return resource|null The cloned resource, null in case it could not be cloned
cloneInputStream
php
deptrac/deptrac
vendor/symfony/console/Helper/QuestionHelper.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/QuestionHelper.php
MIT
public function setColumnStyle(int $columnIndex, TableStyle|string $name) : static { $this->columnStyles[$columnIndex] = $this->resolveStyle($name); return $this; }
Sets table column style. @param TableStyle|string $name The style name or a TableStyle instance @return $this
setColumnStyle
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
public function getColumnStyle(int $columnIndex) : TableStyle { return $this->columnStyles[$columnIndex] ?? $this->getStyle(); }
Gets the current style for a column. If style was not set, it returns the global table style.
getColumnStyle
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
public function setColumnWidth(int $columnIndex, int $width) : static { $this->columnWidths[$columnIndex] = $width; return $this; }
Sets the minimum width of a column. @return $this
setColumnWidth
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
public function setColumnWidths(array $widths) : static { $this->columnWidths = []; foreach ($widths as $index => $width) { $this->setColumnWidth($index, $width); } return $this; }
Sets the minimum width of all columns. @return $this
setColumnWidths
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
public function setColumnMaxWidth(int $columnIndex, int $width) : static { if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) { throw new \LogicException(\sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, \get_debug_type($this->output->getFormatter()))); } $this->columnMaxWidths[$columnIndex] = $width; return $this; }
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
setColumnMaxWidth
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
public function appendRow(TableSeparator|array $row) : static { if (!$this->output instanceof ConsoleSectionOutput) { throw new RuntimeException(\sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__)); } if ($this->rendered) { $this->output->clear($this->calculateRowCount()); } $this->addRow($row); $this->render(); return $this; }
Adds a row to the table, and re-renders the table. @return $this
appendRow
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
public function render() { $divider = new TableSeparator(); $isCellWithColspan = static fn($cell) => $cell instanceof TableCell && $cell->getColspan() >= 2; $horizontal = self::DISPLAY_ORIENTATION_HORIZONTAL === $this->displayOrientation; $vertical = self::DISPLAY_ORIENTATION_VERTICAL === $this->displayOrientation; $rows = []; if ($horizontal) { foreach ($this->headers[0] ?? [] as $i => $header) { $rows[$i] = [$header]; foreach ($this->rows as $row) { if ($row instanceof TableSeparator) { continue; } if (isset($row[$i])) { $rows[$i][] = $row[$i]; } elseif ($isCellWithColspan($rows[$i][0])) { // Noop, there is a "title" } else { $rows[$i][] = null; } } } } elseif ($vertical) { $formatter = $this->output->getFormatter(); $maxHeaderLength = \array_reduce($this->headers[0] ?? [], static fn($max, $header) => \max($max, Helper::width(Helper::removeDecoration($formatter, $header))), 0); foreach ($this->rows as $row) { if ($row instanceof TableSeparator) { continue; } if ($rows) { $rows[] = [$divider]; } $containsColspan = \false; foreach ($row as $cell) { if ($containsColspan = $isCellWithColspan($cell)) { break; } } $headers = $this->headers[0] ?? []; $maxRows = \max(\count($headers), \count($row)); for ($i = 0; $i < $maxRows; ++$i) { $cell = (string) ($row[$i] ?? ''); $eol = \str_contains($cell, "\r\n") ? "\r\n" : "\n"; $parts = \explode($eol, $cell); foreach ($parts as $idx => $part) { if ($headers && !$containsColspan) { if (0 === $idx) { $rows[] = [\sprintf('<comment>%s%s</>: %s', \str_repeat(' ', $maxHeaderLength - Helper::width(Helper::removeDecoration($formatter, $headers[$i] ?? ''))), $headers[$i] ?? '', $part)]; } else { $rows[] = [\sprintf('%s %s', \str_pad('', $maxHeaderLength, ' ', \STR_PAD_LEFT), $part)]; } } elseif ('' !== $cell) { $rows[] = [$part]; } } } } } else { $rows = \array_merge($this->headers, [$divider], $this->rows); } $this->calculateNumberOfColumns($rows); $rowGroups = $this->buildTableRows($rows); $this->calculateColumnsWidth($rowGroups); $isHeader = !$horizontal; $isFirstRow = $horizontal; $hasTitle = (bool) $this->headerTitle; foreach ($rowGroups as $rowGroup) { $isHeaderSeparatorRendered = \false; foreach ($rowGroup as $row) { if ($divider === $row) { $isHeader = \false; $isFirstRow = \true; continue; } if ($row instanceof TableSeparator) { $this->renderRowSeparator(); continue; } if (!$row) { continue; } if ($isHeader && !$isHeaderSeparatorRendered) { $this->renderRowSeparator(self::SEPARATOR_TOP, $hasTitle ? $this->headerTitle : null, $hasTitle ? $this->style->getHeaderTitleFormat() : null); $hasTitle = \false; $isHeaderSeparatorRendered = \true; } if ($isFirstRow) { $this->renderRowSeparator($horizontal ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, $hasTitle ? $this->headerTitle : null, $hasTitle ? $this->style->getHeaderTitleFormat() : null); $isFirstRow = \false; $hasTitle = \false; } if ($vertical) { $isHeader = \false; $isFirstRow = \false; } if ($horizontal) { $this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat()); } else { $this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat()); } } } $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat()); $this->cleanup(); $this->rendered = \true; }
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 | +---------------+-----------------------+------------------+ @return void
render
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
private function renderRow(array $row, string $cellFormat, ?string $firstCellFormat = null) : void { $rowContent = $this->renderColumnSeparator(self::BORDER_OUTSIDE); $columns = $this->getRowColumns($row); $last = \count($columns) - 1; foreach ($columns as $i => $column) { if ($firstCellFormat && 0 === $i) { $rowContent .= $this->renderCell($row, $column, $firstCellFormat); } else { $rowContent .= $this->renderCell($row, $column, $cellFormat); } $rowContent .= $this->renderColumnSeparator($last === $i ? self::BORDER_OUTSIDE : self::BORDER_INSIDE); } $this->output->writeln($rowContent); }
Renders table row. Example: | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
renderRow
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
private function calculateNumberOfColumns(array $rows) : void { $columns = [0]; foreach ($rows as $row) { if ($row instanceof TableSeparator) { continue; } $columns[] = $this->getNumberOfColumns($row); } $this->numberOfColumns = \max($columns); }
Calculate number of columns for this table.
calculateNumberOfColumns
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
private function fillNextRows(array $rows, int $line) : array { $unmergedRows = []; foreach ($rows[$line] as $column => $cell) { if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !$cell instanceof \Stringable) { throw new InvalidArgumentException(\sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', \get_debug_type($cell))); } if ($cell instanceof TableCell && $cell->getRowspan() > 1) { $nbLines = $cell->getRowspan() - 1; $lines = [$cell]; if (\str_contains($cell, "\n")) { $eol = \str_contains($cell, "\r\n") ? "\r\n" : "\n"; $lines = \explode($eol, \str_replace($eol, '<fg=default;bg=default>' . $eol . '</>', $cell)); $nbLines = \count($lines) > $nbLines ? \substr_count($cell, $eol) : $nbLines; $rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]); unset($lines[0]); } // create a two dimensional array (rowspan x colspan) $unmergedRows = \array_replace_recursive(\array_fill($line + 1, $nbLines, []), $unmergedRows); foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) { $value = $lines[$unmergedRowKey - $line] ?? ''; $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]); if ($nbLines === $unmergedRowKey - $line) { break; } } } } foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) { // we need to know if $unmergedRow will be merged or inserted into $rows if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && $this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns) { foreach ($unmergedRow as $cellKey => $cell) { // insert cell into row at cellKey position \array_splice($rows[$unmergedRowKey], $cellKey, 0, [$cell]); } } else { $row = $this->copyRow($rows, $unmergedRowKey - 1); foreach ($unmergedRow as $column => $cell) { if (!empty($cell)) { $row[$column] = $unmergedRow[$column]; } } \array_splice($rows, $unmergedRowKey, 0, [$row]); } } return $rows; }
fill rows that contains rowspan > 1. @throws InvalidArgumentException
fillNextRows
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
private function fillCells(iterable $row) : iterable { $newRow = []; foreach ($row as $column => $cell) { $newRow[] = $cell; if ($cell instanceof TableCell && $cell->getColspan() > 1) { foreach (\range($column + 1, $column + $cell->getColspan() - 1) as $position) { // insert empty value at column position $newRow[] = ''; } } } return $newRow ?: $row; }
fill cells for a row that contains colspan > 1.
fillCells
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
private function getNumberOfColumns(array $row) : int { $columns = \count($row); foreach ($row as $column) { $columns += $column instanceof TableCell ? $column->getColspan() - 1 : 0; } return $columns; }
Gets number of columns by row.
getNumberOfColumns
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
private function getRowColumns(array $row) : array { $columns = \range(0, $this->numberOfColumns - 1); foreach ($row as $cellKey => $cell) { if ($cell instanceof TableCell && $cell->getColspan() > 1) { // exclude grouped columns. $columns = \array_diff($columns, \range($cellKey + 1, $cellKey + $cell->getColspan() - 1)); } } return $columns; }
Gets list of columns for the given row.
getRowColumns
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
private function cleanup() : void { $this->effectiveColumnWidths = []; unset($this->numberOfColumns); }
Called after rendering to cleanup cache data.
cleanup
php
deptrac/deptrac
vendor/symfony/console/Helper/Table.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/Table.php
MIT
public function getTagOptions() : array { return \array_filter($this->getOptions(), fn($key) => \in_array($key, self::TAG_OPTIONS) && isset($this->options[$key]), \ARRAY_FILTER_USE_KEY); }
Gets options we need for tag for example fg, bg. @return string[]
getTagOptions
php
deptrac/deptrac
vendor/symfony/console/Helper/TableCellStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableCellStyle.php
MIT
public function setPaddingChar(string $paddingChar) : static { if (!$paddingChar) { throw new LogicException('The padding char must not be empty.'); } $this->paddingChar = $paddingChar; return $this; }
Sets padding character, used for cell padding. @return $this
setPaddingChar
php
deptrac/deptrac
vendor/symfony/console/Helper/TableStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableStyle.php
MIT
public function getPaddingChar() : string { return $this->paddingChar; }
Gets padding character, used for cell padding.
getPaddingChar
php
deptrac/deptrac
vendor/symfony/console/Helper/TableStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableStyle.php
MIT
public function setDefaultCrossingChar(string $char) : self { return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char); }
Sets default crossing character used for each cross. @see {@link setCrossingChars()} for setting each crossing individually.
setDefaultCrossingChar
php
deptrac/deptrac
vendor/symfony/console/Helper/TableStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableStyle.php
MIT
public function setCellHeaderFormat(string $cellHeaderFormat) : static { $this->cellHeaderFormat = $cellHeaderFormat; return $this; }
Sets header cell format. @return $this
setCellHeaderFormat
php
deptrac/deptrac
vendor/symfony/console/Helper/TableStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableStyle.php
MIT
public function setCellRowFormat(string $cellRowFormat) : static { $this->cellRowFormat = $cellRowFormat; return $this; }
Sets row cell format. @return $this
setCellRowFormat
php
deptrac/deptrac
vendor/symfony/console/Helper/TableStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableStyle.php
MIT
public function setCellRowContentFormat(string $cellRowContentFormat) : static { $this->cellRowContentFormat = $cellRowContentFormat; return $this; }
Sets row cell content format. @return $this
setCellRowContentFormat
php
deptrac/deptrac
vendor/symfony/console/Helper/TableStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableStyle.php
MIT
public function setBorderFormat(string $borderFormat) : static { $this->borderFormat = $borderFormat; return $this; }
Sets table border format. @return $this
setBorderFormat
php
deptrac/deptrac
vendor/symfony/console/Helper/TableStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableStyle.php
MIT
public function setPadType(int $padType) : static { if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], \true)) { throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); } $this->padType = $padType; return $this; }
Sets cell padding type. @return $this
setPadType
php
deptrac/deptrac
vendor/symfony/console/Helper/TableStyle.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Helper/TableStyle.php
MIT
private function parseShortOptionSet(string $name) : void { $len = \strlen($name); for ($i = 0; $i < $len; ++$i) { if (!$this->definition->hasShortcut($name[$i])) { $encoding = \mb_detect_encoding($name, null, \true); throw new RuntimeException(\sprintf('The "-%s" option does not exist.', \false === $encoding ? $name[$i] : \mb_substr($name, $i, 1, $encoding))); } $option = $this->definition->getOptionForShortcut($name[$i]); if ($option->acceptValue()) { $this->addLongOption($option->getName(), $i === $len - 1 ? null : \substr($name, $i + 1)); break; } else { $this->addLongOption($option->getName(), null); } } }
Parses a short option set. @throws RuntimeException When option given doesn't exist
parseShortOptionSet
php
deptrac/deptrac
vendor/symfony/console/Input/ArgvInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArgvInput.php
MIT
private function parseArgument(string $token) : void { $c = \count($this->arguments); // if input is expecting another argument, add it if ($this->definition->hasArgument($c)) { $arg = $this->definition->getArgument($c); $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token; // if last argument isArray(), append token to last argument } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { $arg = $this->definition->getArgument($c - 1); $this->arguments[$arg->getName()][] = $token; // unexpected argument } else { $all = $this->definition->getArguments(); $symfonyCommandName = null; if (($inputArgument = $all[$key = \array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) { $symfonyCommandName = $this->arguments['command'] ?? null; unset($all[$key]); } if (\count($all)) { if ($symfonyCommandName) { $message = \sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, \implode('" "', \array_keys($all))); } else { $message = \sprintf('Too many arguments, expected arguments "%s".', \implode('" "', \array_keys($all))); } } elseif ($symfonyCommandName) { $message = \sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token); } else { $message = \sprintf('No arguments expected, got "%s".', $token); } throw new RuntimeException($message); } }
Parses an argument. @throws RuntimeException When too many arguments are given
parseArgument
php
deptrac/deptrac
vendor/symfony/console/Input/ArgvInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArgvInput.php
MIT
private function addShortOption(string $shortcut, mixed $value) : void { if (!$this->definition->hasShortcut($shortcut)) { throw new RuntimeException(\sprintf('The "-%s" option does not exist.', $shortcut)); } $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); }
Adds a short option value. @throws RuntimeException When option given doesn't exist
addShortOption
php
deptrac/deptrac
vendor/symfony/console/Input/ArgvInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArgvInput.php
MIT
private function addLongOption(string $name, mixed $value) : void { if (!$this->definition->hasOption($name)) { if (!$this->definition->hasNegation($name)) { throw new RuntimeException(\sprintf('The "--%s" option does not exist.', $name)); } $optionName = $this->definition->negationToName($name); if (null !== $value) { throw new RuntimeException(\sprintf('The "--%s" option does not accept a value.', $name)); } $this->options[$optionName] = \false; return; } $option = $this->definition->getOption($name); if (null !== $value && !$option->acceptValue()) { throw new RuntimeException(\sprintf('The "--%s" option does not accept a value.', $name)); } if (\in_array($value, ['', null], \true) && $option->acceptValue() && \count($this->parsed)) { // if option accepts an optional or mandatory argument // let's see if there is one provided $next = \array_shift($this->parsed); if (isset($next[0]) && '-' !== $next[0] || \in_array($next, ['', null], \true)) { $value = $next; } else { \array_unshift($this->parsed, $next); } } if (null === $value) { if ($option->isValueRequired()) { throw new RuntimeException(\sprintf('The "--%s" option requires a value.', $name)); } if (!$option->isArray() && !$option->isValueOptional()) { $value = \true; } } if ($option->isArray()) { $this->options[$name][] = $value; } else { $this->options[$name] = $value; } }
Adds a long option value. @throws RuntimeException When option given doesn't exist
addLongOption
php
deptrac/deptrac
vendor/symfony/console/Input/ArgvInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArgvInput.php
MIT
public function __toString() : string { $tokens = \array_map(function ($token) { if (\preg_match('{^(-[^=]+=)(.+)}', $token, $match)) { return $match[1] . $this->escapeToken($match[2]); } if ($token && '-' !== $token[0]) { return $this->escapeToken($token); } return $token; }, $this->tokens); return \implode(' ', $tokens); }
Returns a stringified representation of the args passed to the command.
__toString
php
deptrac/deptrac
vendor/symfony/console/Input/ArgvInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArgvInput.php
MIT
public function __toString() : string { $params = []; foreach ($this->parameters as $param => $val) { if ($param && \is_string($param) && '-' === $param[0]) { $glue = '-' === $param[1] ? '=' : ' '; if (\is_array($val)) { foreach ($val as $v) { $params[] = $param . ('' != $v ? $glue . $this->escapeToken($v) : ''); } } else { $params[] = $param . ('' != $val ? $glue . $this->escapeToken($val) : ''); } } else { $params[] = \is_array($val) ? \implode(' ', \array_map($this->escapeToken(...), $val)) : $this->escapeToken($val); } } return \implode(' ', $params); }
Returns a stringified representation of the args passed to the command.
__toString
php
deptrac/deptrac
vendor/symfony/console/Input/ArrayInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArrayInput.php
MIT
private function addShortOption(string $shortcut, mixed $value) : void { if (!$this->definition->hasShortcut($shortcut)) { throw new InvalidOptionException(\sprintf('The "-%s" option does not exist.', $shortcut)); } $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); }
Adds a short option value. @throws InvalidOptionException When option given doesn't exist
addShortOption
php
deptrac/deptrac
vendor/symfony/console/Input/ArrayInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArrayInput.php
MIT
private function addLongOption(string $name, mixed $value) : void { if (!$this->definition->hasOption($name)) { if (!$this->definition->hasNegation($name)) { throw new InvalidOptionException(\sprintf('The "--%s" option does not exist.', $name)); } $optionName = $this->definition->negationToName($name); $this->options[$optionName] = \false; return; } $option = $this->definition->getOption($name); if (null === $value) { if ($option->isValueRequired()) { throw new InvalidOptionException(\sprintf('The "--%s" option requires a value.', $name)); } if (!$option->isValueOptional()) { $value = \true; } } $this->options[$name] = $value; }
Adds a long option value. @throws InvalidOptionException When option given doesn't exist @throws InvalidOptionException When a required value is missing
addLongOption
php
deptrac/deptrac
vendor/symfony/console/Input/ArrayInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArrayInput.php
MIT
private function addArgument(string|int $name, mixed $value) : void { if (!$this->definition->hasArgument($name)) { throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); } $this->arguments[$name] = $value; }
Adds an argument value. @throws InvalidArgumentException When argument given doesn't exist
addArgument
php
deptrac/deptrac
vendor/symfony/console/Input/ArrayInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/ArrayInput.php
MIT
public function escapeToken(string $token) : string { return \preg_match('{^[\\w-]+$}', $token) ? $token : \escapeshellarg($token); }
Escapes a token through escapeshellarg if it contains unsafe chars.
escapeToken
php
deptrac/deptrac
vendor/symfony/console/Input/Input.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/Input.php
MIT
public function __construct(string $name, ?int $mode = null, string $description = '', string|bool|int|float|array|null $default = null, \Closure|array $suggestedValues = []) { if (null === $mode) { $mode = self::OPTIONAL; } elseif ($mode > 7 || $mode < 1) { throw new InvalidArgumentException(\sprintf('Argument mode "%s" is not valid.', $mode)); } $this->name = $name; $this->mode = $mode; $this->description = $description; $this->suggestedValues = $suggestedValues; $this->setDefault($default); }
@param string $name The argument name @param int|null $mode The argument mode: a bit mask of self::REQUIRED, self::OPTIONAL and self::IS_ARRAY @param string $description A description text @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only) @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion @throws InvalidArgumentException When argument mode is not valid
__construct
php
deptrac/deptrac
vendor/symfony/console/Input/InputArgument.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputArgument.php
MIT
public function isRequired() : bool { return self::REQUIRED === (self::REQUIRED & $this->mode); }
Returns true if the argument is required. @return bool true if parameter mode is self::REQUIRED, false otherwise
isRequired
php
deptrac/deptrac
vendor/symfony/console/Input/InputArgument.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputArgument.php
MIT
public function isArray() : bool { return self::IS_ARRAY === (self::IS_ARRAY & $this->mode); }
Returns true if the argument can take multiple values. @return bool true if mode is self::IS_ARRAY, false otherwise
isArray
php
deptrac/deptrac
vendor/symfony/console/Input/InputArgument.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputArgument.php
MIT
public function setDefault(string|bool|int|float|array|null $default = null) { if (1 > \func_num_args()) { \DEPTRAC_INTERNAL\trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); } if ($this->isRequired() && null !== $default) { throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); } if ($this->isArray()) { if (null === $default) { $default = []; } elseif (!\is_array($default)) { throw new LogicException('A default value for an array argument must be an array.'); } } $this->default = $default; }
Sets the default value. @return void @throws LogicException When incorrect default value is given
setDefault
php
deptrac/deptrac
vendor/symfony/console/Input/InputArgument.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputArgument.php
MIT
public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void { $values = $this->suggestedValues; if ($values instanceof \Closure && !\is_array($values = $values($input))) { throw new LogicException(\sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->name, \get_debug_type($values))); } if ($values) { $suggestions->suggestValues($values); } }
Adds suggestions to $suggestions for the current completion input. @see Command::complete()
complete
php
deptrac/deptrac
vendor/symfony/console/Input/InputArgument.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputArgument.php
MIT
public function __construct(array $definition = []) { $this->setDefinition($definition); }
@param array $definition An array of InputArgument and InputOption instance
__construct
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function setDefinition(array $definition) { $arguments = []; $options = []; foreach ($definition as $item) { if ($item instanceof InputOption) { $options[] = $item; } else { $arguments[] = $item; } } $this->setArguments($arguments); $this->setOptions($options); }
Sets the definition of the input. @return void
setDefinition
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function setArguments(array $arguments = []) { $this->arguments = []; $this->requiredCount = 0; $this->lastOptionalArgument = null; $this->lastArrayArgument = null; $this->addArguments($arguments); }
Sets the InputArgument objects. @param InputArgument[] $arguments An array of InputArgument objects @return void
setArguments
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function addArguments(?array $arguments = []) { if (null !== $arguments) { foreach ($arguments as $argument) { $this->addArgument($argument); } } }
Adds an array of InputArgument objects. @param InputArgument[] $arguments An array of InputArgument objects @return void
addArguments
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function addArgument(InputArgument $argument) { if (isset($this->arguments[$argument->getName()])) { throw new LogicException(\sprintf('An argument with name "%s" already exists.', $argument->getName())); } if (null !== $this->lastArrayArgument) { throw new LogicException(\sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName())); } if ($argument->isRequired() && null !== $this->lastOptionalArgument) { throw new LogicException(\sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName())); } if ($argument->isArray()) { $this->lastArrayArgument = $argument; } if ($argument->isRequired()) { ++$this->requiredCount; } else { $this->lastOptionalArgument = $argument; } $this->arguments[$argument->getName()] = $argument; }
@return void @throws LogicException When incorrect argument is given
addArgument
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function getArgument(string|int $name) : InputArgument { if (!$this->hasArgument($name)) { throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); } $arguments = \is_int($name) ? \array_values($this->arguments) : $this->arguments; return $arguments[$name]; }
Returns an InputArgument by name or by position. @throws InvalidArgumentException When argument given doesn't exist
getArgument
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function hasArgument(string|int $name) : bool { $arguments = \is_int($name) ? \array_values($this->arguments) : $this->arguments; return isset($arguments[$name]); }
Returns true if an InputArgument object exists by name or position.
hasArgument
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function getArguments() : array { return $this->arguments; }
Gets the array of InputArgument objects. @return InputArgument[]
getArguments
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function getArgumentRequiredCount() : int { return $this->requiredCount; }
Returns the number of required InputArguments.
getArgumentRequiredCount
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function getArgumentDefaults() : array { $values = []; foreach ($this->arguments as $argument) { $values[$argument->getName()] = $argument->getDefault(); } return $values; }
@return array<string|bool|int|float|array|null>
getArgumentDefaults
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function setOptions(array $options = []) { $this->options = []; $this->shortcuts = []; $this->negations = []; $this->addOptions($options); }
Sets the InputOption objects. @param InputOption[] $options An array of InputOption objects @return void
setOptions
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function addOptions(array $options = []) { foreach ($options as $option) { $this->addOption($option); } }
Adds an array of InputOption objects. @param InputOption[] $options An array of InputOption objects @return void
addOptions
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function addOption(InputOption $option) { if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { throw new LogicException(\sprintf('An option named "%s" already exists.', $option->getName())); } if (isset($this->negations[$option->getName()])) { throw new LogicException(\sprintf('An option named "%s" already exists.', $option->getName())); } if ($option->getShortcut()) { foreach (\explode('|', $option->getShortcut()) as $shortcut) { if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) { throw new LogicException(\sprintf('An option with shortcut "%s" already exists.', $shortcut)); } } } $this->options[$option->getName()] = $option; if ($option->getShortcut()) { foreach (\explode('|', $option->getShortcut()) as $shortcut) { $this->shortcuts[$shortcut] = $option->getName(); } } if ($option->isNegatable()) { $negatedName = 'no-' . $option->getName(); if (isset($this->options[$negatedName])) { throw new LogicException(\sprintf('An option named "%s" already exists.', $negatedName)); } $this->negations[$negatedName] = $option->getName(); } }
@return void @throws LogicException When option given already exist
addOption
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function getOption(string $name) : InputOption { if (!$this->hasOption($name)) { throw new InvalidArgumentException(\sprintf('The "--%s" option does not exist.', $name)); } return $this->options[$name]; }
Returns an InputOption by name. @throws InvalidArgumentException When option given doesn't exist
getOption
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function hasOption(string $name) : bool { return isset($this->options[$name]); }
Returns true if an InputOption object exists by name. This method can't be used to check if the user included the option when executing the command (use getOption() instead).
hasOption
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function getOptions() : array { return $this->options; }
Gets the array of InputOption objects. @return InputOption[]
getOptions
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function hasShortcut(string $name) : bool { return isset($this->shortcuts[$name]); }
Returns true if an InputOption object exists by shortcut.
hasShortcut
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function hasNegation(string $name) : bool { return isset($this->negations[$name]); }
Returns true if an InputOption object exists by negated name.
hasNegation
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function getOptionDefaults() : array { $values = []; foreach ($this->options as $option) { $values[$option->getName()] = $option->getDefault(); } return $values; }
@return array<string|bool|int|float|array|null>
getOptionDefaults
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function shortcutToName(string $shortcut) : string { if (!isset($this->shortcuts[$shortcut])) { throw new InvalidArgumentException(\sprintf('The "-%s" option does not exist.', $shortcut)); } return $this->shortcuts[$shortcut]; }
Returns the InputOption name given a shortcut. @throws InvalidArgumentException When option given does not exist @internal
shortcutToName
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function negationToName(string $negation) : string { if (!isset($this->negations[$negation])) { throw new InvalidArgumentException(\sprintf('The "--%s" option does not exist.', $negation)); } return $this->negations[$negation]; }
Returns the InputOption name given a negation. @throws InvalidArgumentException When option given does not exist @internal
negationToName
php
deptrac/deptrac
vendor/symfony/console/Input/InputDefinition.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputDefinition.php
MIT
public function acceptValue() : bool { return $this->isValueRequired() || $this->isValueOptional(); }
Returns true if the option accepts a value. @return bool true if value mode is not self::VALUE_NONE, false otherwise
acceptValue
php
deptrac/deptrac
vendor/symfony/console/Input/InputOption.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputOption.php
MIT
public function isValueRequired() : bool { return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode); }
Returns true if the option requires a value. @return bool true if value mode is self::VALUE_REQUIRED, false otherwise
isValueRequired
php
deptrac/deptrac
vendor/symfony/console/Input/InputOption.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputOption.php
MIT
public function isValueOptional() : bool { return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode); }
Returns true if the option takes an optional value. @return bool true if value mode is self::VALUE_OPTIONAL, false otherwise
isValueOptional
php
deptrac/deptrac
vendor/symfony/console/Input/InputOption.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputOption.php
MIT
public function isArray() : bool { return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); }
Returns true if the option can take multiple values. @return bool true if mode is self::VALUE_IS_ARRAY, false otherwise
isArray
php
deptrac/deptrac
vendor/symfony/console/Input/InputOption.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputOption.php
MIT
public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void { $values = $this->suggestedValues; if ($values instanceof \Closure && !\is_array($values = $values($input))) { throw new LogicException(\sprintf('Closure for option "%s" must return an array. Got "%s".', $this->name, \get_debug_type($values))); } if ($values) { $suggestions->suggestValues($values); } }
Adds suggestions to $suggestions for the current completion input. @see Command::complete()
complete
php
deptrac/deptrac
vendor/symfony/console/Input/InputOption.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputOption.php
MIT
public function equals(self $option) : bool { return $option->getName() === $this->getName() && $option->getShortcut() === $this->getShortcut() && $option->getDefault() === $this->getDefault() && $option->isNegatable() === $this->isNegatable() && $option->isArray() === $this->isArray() && $option->isValueRequired() === $this->isValueRequired() && $option->isValueOptional() === $this->isValueOptional(); }
Checks whether the given option equals this one.
equals
php
deptrac/deptrac
vendor/symfony/console/Input/InputOption.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/InputOption.php
MIT
public function __construct(string $input) { parent::__construct([]); $this->setTokens($this->tokenize($input)); }
@param string $input A string representing the parameters from the CLI
__construct
php
deptrac/deptrac
vendor/symfony/console/Input/StringInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/StringInput.php
MIT
private function tokenize(string $input) : array { $tokens = []; $length = \strlen($input); $cursor = 0; $token = null; while ($cursor < $length) { if ('\\' === $input[$cursor]) { $token .= $input[++$cursor] ?? ''; ++$cursor; continue; } if (\preg_match('/\\s+/A', $input, $match, 0, $cursor)) { if (null !== $token) { $tokens[] = $token; $token = null; } } elseif (\preg_match('/([^="\'\\s]+?)(=?)(' . self::REGEX_QUOTED_STRING . '+)/A', $input, $match, 0, $cursor)) { $token .= $match[1] . $match[2] . \stripcslashes(\str_replace(['"\'', '\'"', '\'\'', '""'], '', \substr($match[3], 1, -1))); } elseif (\preg_match('/' . self::REGEX_QUOTED_STRING . '/A', $input, $match, 0, $cursor)) { $token .= \stripcslashes(\substr($match[0], 1, -1)); } elseif (\preg_match('/' . self::REGEX_UNQUOTED_STRING . '/A', $input, $match, 0, $cursor)) { $token .= $match[1]; } else { // should never happen throw new InvalidArgumentException(\sprintf('Unable to parse input near "... %s ...".', \substr($input, $cursor, 10))); } $cursor += \strlen($match[0]); } if (null !== $token) { $tokens[] = $token; } return $tokens; }
Tokenizes a string. @throws InvalidArgumentException When unable to parse input (should never happen)
tokenize
php
deptrac/deptrac
vendor/symfony/console/Input/StringInput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Input/StringInput.php
MIT
public function hasErrored() : bool { return $this->errored; }
Returns true when any messages have been logged at error levels.
hasErrored
php
deptrac/deptrac
vendor/symfony/console/Logger/ConsoleLogger.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Logger/ConsoleLogger.php
MIT
private function interpolate(string $message, array $context) : string { if (!\str_contains($message, '{')) { return $message; } $replacements = []; foreach ($context as $key => $val) { if (null === $val || \is_scalar($val) || $val instanceof \Stringable) { $replacements["{{$key}}"] = $val; } elseif ($val instanceof \DateTimeInterface) { $replacements["{{$key}}"] = $val->format(\DateTimeInterface::RFC3339); } elseif (\is_object($val)) { $replacements["{{$key}}"] = '[object ' . $val::class . ']'; } else { $replacements["{{$key}}"] = '[' . \gettype($val) . ']'; } } return \strtr($message, $replacements); }
Interpolates context values into the message placeholders. @author PHP Framework Interoperability Group
interpolate
php
deptrac/deptrac
vendor/symfony/console/Logger/ConsoleLogger.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Logger/ConsoleLogger.php
MIT
public function convertFromHexToAnsiColorCode(string $hexColor) : string { $hexColor = \str_replace('#', '', $hexColor); if (3 === \strlen($hexColor)) { $hexColor = $hexColor[0] . $hexColor[0] . $hexColor[1] . $hexColor[1] . $hexColor[2] . $hexColor[2]; } if (6 !== \strlen($hexColor)) { throw new InvalidArgumentException(\sprintf('Invalid "#%s" color.', $hexColor)); } $color = \hexdec($hexColor); $r = $color >> 16 & 255; $g = $color >> 8 & 255; $b = $color & 255; return match ($this) { self::Ansi4 => (string) $this->convertFromRGB($r, $g, $b), self::Ansi8 => '8;5;' . (string) $this->convertFromRGB($r, $g, $b), self::Ansi24 => \sprintf('8;2;%d;%d;%d', $r, $g, $b), }; }
Converts an RGB hexadecimal color to the corresponding Ansi code.
convertFromHexToAnsiColorCode
php
deptrac/deptrac
vendor/symfony/console/Output/AnsiColorMode.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/AnsiColorMode.php
MIT
public function fetch() : string { $content = $this->buffer; $this->buffer = ''; return $content; }
Empties buffer and returns its content.
fetch
php
deptrac/deptrac
vendor/symfony/console/Output/BufferedOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/BufferedOutput.php
MIT
public function __construct(int $verbosity = self::VERBOSITY_NORMAL, ?bool $decorated = null, ?OutputFormatterInterface $formatter = null) { parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); if (null === $formatter) { // for BC reasons, stdErr has it own Formatter only when user don't inject a specific formatter. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated); return; } $actualDecorated = $this->isDecorated(); $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter()); if (null === $decorated) { $this->setDecorated($actualDecorated && $this->stderr->isDecorated()); } }
@param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) @param bool|null $decorated Whether to decorate messages (null for auto-guessing) @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
__construct
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleOutput.php
MIT
protected function hasStdoutSupport() : bool { return \false === $this->isRunningOS400(); }
Returns true if current environment supports writing console output to STDOUT.
hasStdoutSupport
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleOutput.php
MIT
protected function hasStderrSupport() : bool { return \false === $this->isRunningOS400(); }
Returns true if current environment supports writing console output to STDERR.
hasStderrSupport
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleOutput.php
MIT
private function isRunningOS400() : bool { $checks = [\function_exists('php_uname') ? \php_uname('s') : '', \getenv('OSTYPE'), \PHP_OS]; return \false !== \stripos(\implode(';', $checks), 'OS400'); }
Checks if current executing environment is IBM iSeries (OS400), which doesn't properly convert character-encodings between ASCII to EBCDIC.
isRunningOS400
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleOutput.php
MIT
public function __construct($stream, array &$sections, int $verbosity, bool $decorated, OutputFormatterInterface $formatter) { parent::__construct($stream, $verbosity, $decorated, $formatter); \array_unshift($sections, $this); $this->sections =& $sections; $this->terminal = new Terminal(); }
@param resource $stream @param ConsoleSectionOutput[] $sections
__construct
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleSectionOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleSectionOutput.php
MIT
public function setMaxHeight(int $maxHeight) : void { // when changing max height, clear output of current section and redraw again with the new height $previousMaxHeight = $this->maxHeight; $this->maxHeight = $maxHeight; $existingContent = $this->popStreamContentUntilCurrentSection($previousMaxHeight ? \min($previousMaxHeight, $this->lines) : $this->lines); parent::doWrite($this->getVisibleContent(), \false); parent::doWrite($existingContent, \false); }
Defines a maximum number of lines for this section. When more lines are added, the section will automatically scroll to the end (i.e. remove the first lines to comply with the max height).
setMaxHeight
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleSectionOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleSectionOutput.php
MIT
public function clear(?int $lines = null) { if (empty($this->content) || !$this->isDecorated()) { return; } if ($lines) { \array_splice($this->content, -$lines); } else { $lines = $this->lines; $this->content = []; } $this->lines -= $lines; parent::doWrite($this->popStreamContentUntilCurrentSection($this->maxHeight ? \min($this->maxHeight, $lines) : $lines), \false); }
Clears previous output for this section. @param int $lines Number of lines to clear. If null, then the entire output of this section is cleared @return void
clear
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleSectionOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleSectionOutput.php
MIT
public function overwrite(string|iterable $message) { $this->clear(); $this->writeln($message); }
Overwrites the previous output with a new message. @return void
overwrite
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleSectionOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleSectionOutput.php
MIT
private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection = 0) : string { $numberOfLinesToClear = $numberOfLinesToClearFromCurrentSection; $erasedContent = []; foreach ($this->sections as $section) { if ($section === $this) { break; } $numberOfLinesToClear += $section->maxHeight ? \min($section->lines, $section->maxHeight) : $section->lines; if ('' !== ($sectionContent = $section->getVisibleContent())) { if (!\str_ends_with($sectionContent, \PHP_EOL)) { $sectionContent .= \PHP_EOL; } $erasedContent[] = $sectionContent; } } if ($numberOfLinesToClear > 0) { // move cursor up n lines parent::doWrite(\sprintf("\x1b[%dA", $numberOfLinesToClear), \false); // erase to end of screen parent::doWrite("\x1b[0J", \false); } return \implode('', \array_reverse($erasedContent)); }
At initial stage, cursor is at the end of stream output. This method makes cursor crawl upwards until it hits current section. Then it erases content it crawled through. Optionally, it erases part of current section too.
popStreamContentUntilCurrentSection
php
deptrac/deptrac
vendor/symfony/console/Output/ConsoleSectionOutput.php
https://github.com/deptrac/deptrac/blob/master/vendor/symfony/console/Output/ConsoleSectionOutput.php
MIT