Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+12 -25
View File
@@ -43,11 +43,7 @@ class ApplicationDescription
*/
private $aliases;
/**
* @param string|null $namespace
* @param bool $showHidden
*/
public function __construct(Application $application, $namespace = null, $showHidden = false)
public function __construct(Application $application, string $namespace = null, bool $showHidden = false)
{
$this->application = $application;
$this->namespace = $namespace;
@@ -88,7 +84,7 @@ class ApplicationDescription
public function getCommand($name)
{
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
}
return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
@@ -122,36 +118,27 @@ class ApplicationDescription
}
}
/**
* @return array
*/
private function sortCommands(array $commands)
private function sortCommands(array $commands): array
{
$namespacedCommands = [];
$globalCommands = [];
$sortedCommands = [];
foreach ($commands as $name => $command) {
$key = $this->application->extractNamespace($name, 1);
if (\in_array($key, ['', self::GLOBAL_NAMESPACE], true)) {
$globalCommands[$name] = $command;
if (!$key) {
$globalCommands['_global'][$name] = $command;
} else {
$namespacedCommands[$key][$name] = $command;
}
}
ksort($namespacedCommands);
$namespacedCommands = array_merge($globalCommands, $namespacedCommands);
if ($globalCommands) {
ksort($globalCommands);
$sortedCommands[self::GLOBAL_NAMESPACE] = $globalCommands;
foreach ($namespacedCommands as &$commandsSet) {
ksort($commandsSet);
}
// unset reference to keep scope clear
unset($commandsSet);
if ($namespacedCommands) {
ksort($namespacedCommands);
foreach ($namespacedCommands as $key => $commandsSet) {
ksort($commandsSet);
$sortedCommands[$key] = $commandsSet;
}
}
return $sortedCommands;
return $namespacedCommands;
}
}
+3 -1
View File
@@ -23,7 +23,9 @@ interface DescriptorInterface
/**
* Describes an object if supported.
*
* @param object $object
* @param OutputInterface $output
* @param object $object
* @param array $options
*/
public function describe(OutputInterface $output, $object, array $options = []);
}
+4 -2
View File
@@ -92,6 +92,8 @@ class JsonDescriptor extends Descriptor
/**
* Writes data as json.
*
* @return array|string
*/
private function writeData(array $data, array $options)
{
@@ -110,7 +112,7 @@ class JsonDescriptor extends Descriptor
'is_required' => $argument->isRequired(),
'is_array' => $argument->isArray(),
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
'default' => \INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
];
}
@@ -126,7 +128,7 @@ class JsonDescriptor extends Descriptor
'is_value_required' => $option->isValueRequired(),
'is_multiple' => $option->isArray(),
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault(),
'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
];
}
+17 -17
View File
@@ -140,6 +140,13 @@ class TextDescriptor extends Descriptor
$command->getSynopsis(false);
$command->mergeApplicationDefinition(false);
if ($description = $command->getDescription()) {
$this->writeText('<comment>Description:</comment>', $options);
$this->writeText("\n");
$this->writeText(' '.$description);
$this->writeText("\n\n");
}
$this->writeText('<comment>Usage:</comment>', $options);
foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) {
$this->writeText("\n");
@@ -154,7 +161,8 @@ class TextDescriptor extends Descriptor
$this->writeText("\n");
}
if ($help = $command->getProcessedHelp()) {
$help = $command->getProcessedHelp();
if ($help && $help !== $description) {
$this->writeText("\n");
$this->writeText('<comment>Help:</comment>', $options);
$this->writeText("\n");
@@ -202,9 +210,9 @@ class TextDescriptor extends Descriptor
}
// calculate max. width based on available commands per namespace
$width = $this->getColumnWidth(\call_user_func_array('array_merge', array_map(function ($namespace) use ($commands) {
$width = $this->getColumnWidth(array_merge(...array_values(array_map(function ($namespace) use ($commands) {
return array_intersect($namespace['commands'], array_keys($commands));
}, array_values($namespaces))));
}, $namespaces))));
if ($describedNamespace) {
$this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
@@ -252,10 +260,8 @@ class TextDescriptor extends Descriptor
/**
* Formats command aliases to show them in the command description.
*
* @return string
*/
private function getCommandAliasesText(Command $command)
private function getCommandAliasesText(Command $command): string
{
$text = '';
$aliases = $command->getAliases();
@@ -271,12 +277,10 @@ class TextDescriptor extends Descriptor
* Formats input option/argument default value.
*
* @param mixed $default
*
* @return string
*/
private function formatDefaultValue($default)
private function formatDefaultValue($default): string
{
if (\INF === $default) {
if (INF === $default) {
return 'INF';
}
@@ -290,15 +294,13 @@ class TextDescriptor extends Descriptor
}
}
return str_replace('\\\\', '\\', json_encode($default, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
/**
* @param (Command|string)[] $commands
*
* @return int
*/
private function getColumnWidth(array $commands)
private function getColumnWidth(array $commands): int
{
$widths = [];
@@ -318,10 +320,8 @@ class TextDescriptor extends Descriptor
/**
* @param InputOption[] $options
*
* @return int
*/
private function calculateTotalWidthForOptions(array $options)
private function calculateTotalWidthForOptions(array $options): int
{
$totalWidth = 0;
foreach ($options as $option) {
+5 -8
View File
@@ -81,6 +81,7 @@ class XmlDescriptor extends Descriptor
}
/**
* @param Application $application
* @param string|null $namespace
*
* @return \DOMDocument
@@ -178,6 +179,8 @@ class XmlDescriptor extends Descriptor
/**
* Writes DOM document.
*
* @return \DOMDocument|string
*/
private function writeDocument(\DOMDocument $dom)
{
@@ -185,10 +188,7 @@ class XmlDescriptor extends Descriptor
$this->write($dom->saveXML());
}
/**
* @return \DOMDocument
*/
private function getInputArgumentDocument(InputArgument $argument)
private function getInputArgumentDocument(InputArgument $argument): \DOMDocument
{
$dom = new \DOMDocument('1.0', 'UTF-8');
@@ -209,10 +209,7 @@ class XmlDescriptor extends Descriptor
return $dom;
}
/**
* @return \DOMDocument
*/
private function getInputOptionDocument(InputOption $option)
private function getInputOptionDocument(InputOption $option): \DOMDocument
{
$dom = new \DOMDocument('1.0', 'UTF-8');