function ConfigCommand::listConfiguration
Display the contents of the file in a pretty formatted way
Parameters
array<mixed[]|bool|string> $contents:
array<mixed[]|string> $rawContents:
1 call to ConfigCommand::listConfiguration()
- ConfigCommand::execute in vendor/
composer/ composer/ src/ Composer/ Command/ ConfigCommand.php
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ ConfigCommand.php, line 952
Class
- ConfigCommand
- @author Joshua Estes <Joshua.Estes@iostudio.com> @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\CommandCode
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, ?string $k = null, bool $showSource = false) : void {
$origK = $k;
$io = $this->getIO();
foreach ($contents as $key => $value) {
if ($k === null && !in_array($key, [
'config',
'repositories',
])) {
continue;
}
$rawVal = $rawContents[$key] ?? null;
if (is_array($value) && (!is_numeric(key($value)) || $key === 'repositories' && null === $k)) {
$k .= Preg::replace('{^config\\.}', '', $key . '.');
$this->listConfiguration($value, $rawVal, $output, $k, $showSource);
$k = $origK;
continue;
}
if (is_array($value)) {
$value = array_map(static function ($val) {
return is_array($val) ? json_encode($val) : $val;
}, $value);
$value = '[' . implode(', ', $value) . ']';
}
if (is_bool($value)) {
$value = var_export($value, true);
}
$source = '';
if ($showSource) {
$source = ' (' . $this->config
->getSourceOfValue($k . $key) . ')';
}
if (null !== $k && 0 === strpos($k, 'repositories')) {
$link = 'https://getcomposer.org/doc/05-repositories.md';
}
else {
$id = Preg::replace('{\\..*$}', '', $k === '' || $k === null ? (string) $key : $k);
$id = Preg::replace('{[^a-z0-9]}i', '-', strtolower(trim($id)));
$id = Preg::replace('{-+}', '-', $id);
$link = 'https://getcomposer.org/doc/06-config.md#' . $id;
}
if (is_string($rawVal) && $rawVal !== $value) {
$io->write('[<fg=yellow;href=' . $link . '>' . $k . $key . '</>] <info>' . $rawVal . ' (' . $value . ')</info>' . $source, true, IOInterface::QUIET);
}
else {
$io->write('[<fg=yellow;href=' . $link . '>' . $k . $key . '</>] <info>' . $value . '</info>' . $source, true, IOInterface::QUIET);
}
}
}