From 2922ee9351133236aee150160d139bcabb9cc952 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Tue, 18 Jul 2023 12:48:21 +0200 Subject: [PATCH] chore: update symfony/console to 5.4.24 Signed-off-by: Daniel Kesselberg --- composer.json | 2 +- composer.lock | 16 ++++++++-------- composer/installed.json | 16 ++++++++-------- composer/installed.php | 10 +++++----- symfony/console/Command/Command.php | 8 ++++---- symfony/console/Command/CompleteCommand.php | 4 ++-- .../console/Command/DumpCompletionCommand.php | 18 ++++++++++++------ .../console/Formatter/OutputFormatterStyle.php | 3 ++- symfony/console/Helper/QuestionHelper.php | 17 +++++++++++++---- symfony/console/Helper/Table.php | 2 +- symfony/console/Input/InputArgument.php | 2 +- symfony/console/LICENSE | 2 +- symfony/console/Terminal.php | 17 +++++++++++------ symfony/console/Tester/TesterTrait.php | 8 ++++---- 14 files changed, 73 insertions(+), 52 deletions(-) diff --git a/composer.json b/composer.json index 56dc3fd62..6d23d37a7 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "sabre/dav": "^4.4.0", "scssphp/scssphp": "^1.11", "stecman/symfony-console-completion": "^0.11.0", - "symfony/console": "5.4.19", + "symfony/console": "^5.4.24", "symfony/event-dispatcher": "4.4.30", "symfony/event-dispatcher-contracts": "1.1.9", "symfony/http-foundation": "^5.4.10", diff --git a/composer.lock b/composer.lock index bfaee0601..4650eb1cb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e1b7821d0a3aad7f9caa61aa9f01f44a", + "content-hash": "b5b1750517abfc031e6543455651776f", "packages": [ { "name": "aws/aws-crt-php", @@ -4432,16 +4432,16 @@ }, { "name": "symfony/console", - "version": "v5.4.19", + "version": "v5.4.24", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "dccb8d251a9017d5994c988b034d3e18aaabf740" + "reference": "560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/dccb8d251a9017d5994c988b034d3e18aaabf740", - "reference": "dccb8d251a9017d5994c988b034d3e18aaabf740", + "url": "https://api.github.com/repos/symfony/console/zipball/560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8", + "reference": "560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8", "shasum": "" }, "require": { @@ -4506,12 +4506,12 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.19" + "source": "https://github.com/symfony/console/tree/v5.4.24" }, "funding": [ { @@ -4527,7 +4527,7 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:32:19+00:00" + "time": "2023-05-26T05:13:16+00:00" }, { "name": "symfony/css-selector", diff --git a/composer/installed.json b/composer/installed.json index 9a1ca6bb5..d9bf3ca59 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -4627,17 +4627,17 @@ }, { "name": "symfony/console", - "version": "v5.4.19", - "version_normalized": "5.4.19.0", + "version": "v5.4.24", + "version_normalized": "5.4.24.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "dccb8d251a9017d5994c988b034d3e18aaabf740" + "reference": "560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/dccb8d251a9017d5994c988b034d3e18aaabf740", - "reference": "dccb8d251a9017d5994c988b034d3e18aaabf740", + "url": "https://api.github.com/repos/symfony/console/zipball/560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8", + "reference": "560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8", "shasum": "" }, "require": { @@ -4675,7 +4675,7 @@ "symfony/lock": "", "symfony/process": "" }, - "time": "2023-01-01T08:32:19+00:00", + "time": "2023-05-26T05:13:16+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -4704,12 +4704,12 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.19" + "source": "https://github.com/symfony/console/tree/v5.4.24" }, "funding": [ { diff --git a/composer/installed.php b/composer/installed.php index 2bbed24b8..4afcc6fd8 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'nextcloud/3rdparty', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '48b720f4253fffbb463b96fc81248e9f3588e2e0', + 'reference' => '350e2a466ff849c59386e817c849f9e441fc10ab', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), @@ -310,7 +310,7 @@ 'nextcloud/3rdparty' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '48b720f4253fffbb463b96fc81248e9f3588e2e0', + 'reference' => '350e2a466ff849c59386e817c849f9e441fc10ab', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), @@ -689,9 +689,9 @@ 'dev_requirement' => false, ), 'symfony/console' => array( - 'pretty_version' => 'v5.4.19', - 'version' => '5.4.19.0', - 'reference' => 'dccb8d251a9017d5994c988b034d3e18aaabf740', + 'pretty_version' => 'v5.4.24', + 'version' => '5.4.24.0', + 'reference' => '560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), diff --git a/symfony/console/Command/Command.php b/symfony/console/Command/Command.php index e0593e17a..cfa18361e 100644 --- a/symfony/console/Command/Command.php +++ b/symfony/console/Command/Command.php @@ -429,9 +429,9 @@ public function getNativeDefinition() * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) * - * @throws InvalidArgumentException When argument mode is not valid - * * @return $this + * + * @throws InvalidArgumentException When argument mode is not valid */ public function addArgument(string $name, int $mode = null, string $description = '', $default = null) { @@ -450,9 +450,9 @@ public function addArgument(string $name, int $mode = null, string $description * @param int|null $mode The option mode: One of the InputOption::VALUE_* constants * @param mixed $default The default value (must be null for InputOption::VALUE_NONE) * - * @throws InvalidArgumentException If option mode is invalid or incompatible - * * @return $this + * + * @throws InvalidArgumentException If option mode is invalid or incompatible */ public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null) { diff --git a/symfony/console/Command/CompleteCommand.php b/symfony/console/Command/CompleteCommand.php index 11ada4e44..0e35143c3 100644 --- a/symfony/console/Command/CompleteCommand.php +++ b/symfony/console/Command/CompleteCommand.php @@ -155,10 +155,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int throw $e; } - return self::FAILURE; + return 2; } - return self::SUCCESS; + return 0; } private function createCompletionInput(InputInterface $input): CompletionInput diff --git a/symfony/console/Command/DumpCompletionCommand.php b/symfony/console/Command/DumpCompletionCommand.php index 518d606a0..eaf22be1a 100644 --- a/symfony/console/Command/DumpCompletionCommand.php +++ b/symfony/console/Command/DumpCompletionCommand.php @@ -85,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('debug')) { $this->tailDebugLog($commandName, $output); - return self::SUCCESS; + return 0; } $shell = $input->getArgument('shell') ?? self::guessShell(); @@ -102,12 +102,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('Shell not detected, Symfony shell completion only supports "%s").', implode('", "', $supportedShells))); } - return self::INVALID; + return 2; } $output->write(str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, $this->getApplication()->getVersion()], file_get_contents($completionFile))); - return self::SUCCESS; + return 0; } private static function guessShell(): string @@ -132,8 +132,14 @@ private function tailDebugLog(string $commandName, OutputInterface $output): voi */ private function getSupportedShells(): array { - return array_map(function ($f) { - return pathinfo($f, \PATHINFO_EXTENSION); - }, glob(__DIR__.'/../Resources/completion.*')); + $shells = []; + + foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file) { + if (str_starts_with($file->getBasename(), 'completion.') && $file->isFile()) { + $shells[] = $file->getExtension(); + } + } + + return $shells; } } diff --git a/symfony/console/Formatter/OutputFormatterStyle.php b/symfony/console/Formatter/OutputFormatterStyle.php index 0fb36ac63..8370ba058 100644 --- a/symfony/console/Formatter/OutputFormatterStyle.php +++ b/symfony/console/Formatter/OutputFormatterStyle.php @@ -96,7 +96,8 @@ public function apply(string $text) { if (null === $this->handlesHrefGracefully) { $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') - && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100); + && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100) + && !isset($_SERVER['IDEA_INITIAL_DIRECTORY']); } if (null !== $this->href && $this->handlesHrefGracefully) { diff --git a/symfony/console/Helper/QuestionHelper.php b/symfony/console/Helper/QuestionHelper.php index 10602038c..e236be92a 100644 --- a/symfony/console/Helper/QuestionHelper.php +++ b/symfony/console/Helper/QuestionHelper.php @@ -128,7 +128,18 @@ private function doAsk(OutputInterface $output, Question $question) } 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.'); } @@ -500,13 +511,11 @@ private function isInteractiveInput($inputStream): bool return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r')); } - if (!\function_exists('exec')) { + if (!\function_exists('shell_exec')) { return self::$stdinIsInteractive = true; } - exec('stty 2> /dev/null', $output, $status); - - return self::$stdinIsInteractive = 1 !== $status; + return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null')); } /** diff --git a/symfony/console/Helper/Table.php b/symfony/console/Helper/Table.php index 3f2d99145..5c3447ab3 100644 --- a/symfony/console/Helper/Table.php +++ b/symfony/console/Helper/Table.php @@ -805,7 +805,7 @@ private function calculateColumnsWidth(iterable $groups) $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell); $textLength = Helper::width($textContent); if ($textLength > 0) { - $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan())); + $contentColumns = mb_str_split($textContent, ceil($textLength / $cell->getColspan())); foreach ($contentColumns as $position => $content) { $row[$i + $position] = $content; } diff --git a/symfony/console/Input/InputArgument.php b/symfony/console/Input/InputArgument.php index ecfcdad58..8a64f7ac8 100644 --- a/symfony/console/Input/InputArgument.php +++ b/symfony/console/Input/InputArgument.php @@ -32,7 +32,7 @@ class InputArgument /** * @param string $name The argument name - * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL + * @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) * diff --git a/symfony/console/LICENSE b/symfony/console/LICENSE index 008370457..0138f8f07 100644 --- a/symfony/console/LICENSE +++ b/symfony/console/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/symfony/console/Terminal.php b/symfony/console/Terminal.php index 08c53535b..b91e8afc5 100644 --- a/symfony/console/Terminal.php +++ b/symfony/console/Terminal.php @@ -64,20 +64,19 @@ public static function hasSttyAvailable(): bool return self::$stty; } - // skip check if exec function is disabled - if (!\function_exists('exec')) { + // skip check if shell_exec function is disabled + if (!\function_exists('shell_exec')) { return false; } - exec('stty 2>&1', $output, $exitcode); - - return self::$stty = 0 === $exitcode; + return self::$stty = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null')); } private static function initDimensions() { if ('\\' === \DIRECTORY_SEPARATOR) { - if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) { + $ansicon = getenv('ANSICON'); + if (false !== $ansicon && preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim($ansicon), $matches)) { // extract [w, H] from "wxh (WxH)" // or [w, h] from "wxh" self::$width = (int) $matches[1]; @@ -157,6 +156,8 @@ private static function readFromProcess(string $command): ?string 2 => ['pipe', 'w'], ]; + $cp = \function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0; + $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); if (!\is_resource($process)) { return null; @@ -167,6 +168,10 @@ private static function readFromProcess(string $command): ?string fclose($pipes[2]); proc_close($process); + if ($cp) { + sapi_windows_cp_set($cp); + } + return $info; } } diff --git a/symfony/console/Tester/TesterTrait.php b/symfony/console/Tester/TesterTrait.php index 40bc58177..f454bbf9d 100644 --- a/symfony/console/Tester/TesterTrait.php +++ b/symfony/console/Tester/TesterTrait.php @@ -35,9 +35,9 @@ trait TesterTrait /** * Gets the display returned by the last execution of the command or application. * - * @throws \RuntimeException If it's called before the execute method - * * @return string + * + * @throws \RuntimeException If it's called before the execute method */ public function getDisplay(bool $normalize = false) { @@ -103,9 +103,9 @@ public function getOutput() /** * Gets the status code returned by the last execution of the command or application. * - * @throws \RuntimeException If it's called before the execute method - * * @return int + * + * @throws \RuntimeException If it's called before the execute method */ public function getStatusCode() {