From 2cf5da95e0ee185d104dc7d0128021f130e58f2f Mon Sep 17 00:00:00 2001 From: flkasper Date: Mon, 25 Mar 2024 01:55:26 +0100 Subject: [PATCH 01/15] [Console] Add of hidden and deprecation option flags --- src/Symfony/Component/Console/.editorconfig | 7 ++ src/Symfony/Component/Console/CHANGELOG.md | 2 + .../Component/Console/Command/Command.php | 29 +++++- .../Component/Console/Command/HelpCommand.php | 2 + .../Console/Completion/CompletionInput.php | 10 ++- .../Completion/CompletionSuggestions.php | 4 +- .../Console/Descriptor/Descriptor.php | 18 ++++ .../Console/Descriptor/JsonDescriptor.php | 35 +++++--- .../Console/Descriptor/MarkdownDescriptor.php | 14 +-- .../Descriptor/ReStructuredTextDescriptor.php | 16 ++-- .../Console/Descriptor/TextDescriptor.php | 27 +++--- .../Console/Descriptor/XmlDescriptor.php | 27 ++++-- .../Console/Formatter/OutputFormatter.php | 1 + .../Console/Input/InputDefinition.php | 3 + .../Component/Console/Input/InputOption.php | 56 ++++++++++-- .../Tests/Completion/CompletionInputTest.php | 10 +++ .../Output/CompletionOutputTestCase.php | 1 + .../Descriptor/AbstractDescriptorTestCase.php | 8 ++ .../Tests/Descriptor/JsonDescriptorTest.php | 5 +- .../Tests/Descriptor/ObjectsProvider.php | 4 + .../Tests/Fixtures/DescriptorApplication2.php | 1 + .../Tests/Fixtures/DescriptorCommand5.php | 27 ++++++ .../Console/Tests/Fixtures/application_2.json | 90 ++++++++++++++++++- .../Console/Tests/Fixtures/application_2.md | 83 +++++++++++++++++ .../Console/Tests/Fixtures/application_2.rst | 29 ++++++ .../Console/Tests/Fixtures/application_2.txt | 3 +- .../Console/Tests/Fixtures/application_2.xml | 35 ++++++++ .../Console/Tests/Fixtures/command_5.json | 25 ++++++ .../Console/Tests/Fixtures/command_5.md | 21 +++++ .../Console/Tests/Fixtures/command_5.rst | 24 +++++ .../Console/Tests/Fixtures/command_5.txt | 11 +++ .../Console/Tests/Fixtures/command_5.xml | 14 +++ .../command_5_with_hidden_options.json | 34 +++++++ .../Fixtures/command_5_with_hidden_options.md | 29 ++++++ .../command_5_with_hidden_options.rst | 33 +++++++ .../command_5_with_hidden_options.txt | 12 +++ .../command_5_with_hidden_options.xml | 17 ++++ .../Fixtures/input_option_deprecated.json | 10 +++ .../Tests/Fixtures/input_option_deprecated.md | 10 +++ .../Fixtures/input_option_deprecated.rst | 12 +++ .../Fixtures/input_option_deprecated.txt | 1 + .../Fixtures/input_option_deprecated.xml | 4 + .../Tests/Fixtures/input_option_hidden.json | 1 + .../Tests/Fixtures/input_option_hidden.md | 9 ++ .../Tests/Fixtures/input_option_hidden.rst | 11 +++ .../Tests/Fixtures/input_option_hidden.txt | 1 + .../Tests/Fixtures/input_option_hidden.xml | 0 .../Tests/Formatter/OutputFormatterTest.php | 7 ++ .../Tests/Input/InputDefinitionTest.php | 30 +++++-- .../Console/Tests/Input/InputOptionTest.php | 39 +++++++- 50 files changed, 833 insertions(+), 69 deletions(-) create mode 100644 src/Symfony/Component/Console/.editorconfig create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand5.php create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5.json create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5.rst create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5.xml create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.json create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.rst create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.xml create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.json create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.rst create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.xml create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.json create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.md create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.rst create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.xml diff --git a/src/Symfony/Component/Console/.editorconfig b/src/Symfony/Component/Console/.editorconfig new file mode 100644 index 0000000000000..1adf2294b8874 --- /dev/null +++ b/src/Symfony/Component/Console/.editorconfig @@ -0,0 +1,7 @@ +; Unix-style newlines +[Tests/Fixtures/*.{json,md,rst,txt}] +trim_trailing_whitespace = false + +[Tests/Fixtures/*.xml] +trim_trailing_whitespace = false +indent_size = 2 diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index 5a3dd745a06c6..afaea57e09fe3 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -11,6 +11,8 @@ CHANGELOG --- * Add `ArgvInput::getRawTokens()` + * Add `InputOption::HIDDEN` flag to hide options + * Add `InputOption::DEPRECATED` flag to mark options as deprecated 7.0 --- diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 244a419f2e519..4a29d5d85c655 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -235,7 +235,8 @@ public function run(InputInterface $input, OutputInterface $output): int // bind the input against the command specific arguments/options try { - $input->bind($this->getDefinition()); + $inputDefinition = $this->getDefinition(); + $input->bind($inputDefinition); } catch (ExceptionInterface $e) { if (!$this->ignoreValidationErrors) { throw $e; @@ -273,6 +274,10 @@ public function run(InputInterface $input, OutputInterface $output): int $input->validate(); + if (isset($inputDefinition)) { + $this->printDeprecationMessages($inputDefinition, $input, $output); + } + if ($this->code) { $statusCode = ($this->code)($input, $output); } else { @@ -648,6 +653,28 @@ public function getHelper(string $name): HelperInterface return $this->helperSet->get($name); } + private function printDeprecationMessages(InputDefinition $inputDefinition, InputInterface $input, OutputInterface $output): void + { + $deprecationMessages = []; + foreach ($inputDefinition->getOptions() as $inputOption) { + if ($inputOption->isDeprecated()) { + try { + $optionName = $inputOption->getName(); + $optionValue = $input->getOption($optionName); + if (isset($optionValue) && $optionValue !== $inputOption->getDefault()) { + $deprecationMessages[] = sprintf('The option "--%s" is deprecated.', $optionName); + } + } catch (\InvalidArgumentException $exception) { + // option not used, ignore + } + } + } + if (!empty($deprecationMessages)) { + $formatter = $this->getHelper('formatter'); + $output->writeln($formatter->formatBlock($deprecationMessages, 'fg=black;bg=yellow', true)); + } + } + /** * Validates a command name. * diff --git a/src/Symfony/Component/Console/Command/HelpCommand.php b/src/Symfony/Component/Console/Command/HelpCommand.php index a2a72dab4d665..e547faaf71e5a 100644 --- a/src/Symfony/Component/Console/Command/HelpCommand.php +++ b/src/Symfony/Component/Console/Command/HelpCommand.php @@ -37,6 +37,7 @@ protected function configure(): void new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help', fn () => array_keys((new ApplicationDescription($this->getApplication()))->getCommands())), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn () => (new DescriptorHelper())->getFormats()), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), + new InputOption('show-hidden-options', null, InputOption::VALUE_NONE | InputOption::HIDDEN, 'Show hidden options'), ]) ->setDescription('Display help for a command') ->setHelp(<<<'EOF' @@ -67,6 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $helper->describe($output, $this->command, [ 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), + 'show-hidden-options' => $input->getOption('show-hidden-options'), ]); unset($this->command); diff --git a/src/Symfony/Component/Console/Completion/CompletionInput.php b/src/Symfony/Component/Console/Completion/CompletionInput.php index 50febf2dea215..f6f040141907b 100644 --- a/src/Symfony/Component/Console/Completion/CompletionInput.php +++ b/src/Symfony/Component/Console/Completion/CompletionInput.php @@ -198,11 +198,17 @@ private function getOptionFromToken(string $optionToken): ?InputOption if ('-' === ($optionToken[1] ?? ' ')) { // long option name - return $this->definition->hasOption($optionName) ? $this->definition->getOption($optionName) : null; + if ($this->definition->hasOption($optionName) && !$this->definition->getOption($optionName)->isHidden()) { + return $this->definition->getOption($optionName); + } + return null; } // short option name - return $this->definition->hasShortcut($optionName[0]) ? $this->definition->getOptionForShortcut($optionName[0]) : null; + if ($this->definition->hasShortcut($optionName[0]) && !$this->definition->getOptionForShortcut($optionName[0])->isHidden()) { + return $this->definition->getOptionForShortcut($optionName[0]); + } + return null; } /** diff --git a/src/Symfony/Component/Console/Completion/CompletionSuggestions.php b/src/Symfony/Component/Console/Completion/CompletionSuggestions.php index 549bbafbda7e2..d0523fe8e6f46 100644 --- a/src/Symfony/Component/Console/Completion/CompletionSuggestions.php +++ b/src/Symfony/Component/Console/Completion/CompletionSuggestions.php @@ -58,7 +58,9 @@ public function suggestValues(array $values): static */ public function suggestOption(InputOption $option): static { - $this->optionSuggestions[] = $option; + if (!$option->isHidden()) { + $this->optionSuggestions[] = $option; + } return $this; } diff --git a/src/Symfony/Component/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Console/Descriptor/Descriptor.php index 2143a17c3531f..16cfacae7edeb 100644 --- a/src/Symfony/Component/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Console/Descriptor/Descriptor.php @@ -42,6 +42,24 @@ public function describe(OutputInterface $output, object $object, array $options }; } + /** + * Filter hidden options from list. + * @param array $inputOptions + * @return array + */ + protected function removeHiddenOptions(array $inputOptions, array $options = []): array + { + return array_filter($inputOptions, fn(InputOption $option) => !$this->skipHiddenOption($option, $options)); + } + + /** + * Should InputOption be skipped? + */ + protected function skipHiddenOption(InputOption $inputOption, array $options = []): bool + { + return $inputOption->isHidden() && !($options['show-hidden-options'] ?? false); + } + protected function write(string $content, bool $decorated = false): void { $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index 956303709645f..36e96d669fd4c 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -33,6 +33,9 @@ protected function describeInputArgument(InputArgument $argument, array $options protected function describeInputOption(InputOption $option, array $options = []): void { + if ($this->skipHiddenOption($option, $options)) { + return; + } $this->writeData($this->getInputOptionData($option), $options); if ($option->isNegatable()) { $this->writeData($this->getInputOptionData($option, true), $options); @@ -41,12 +44,12 @@ protected function describeInputOption(InputOption $option, array $options = []) protected function describeInputDefinition(InputDefinition $definition, array $options = []): void { - $this->writeData($this->getInputDefinitionData($definition), $options); + $this->writeData($this->getInputDefinitionData($definition, $options), $options); } protected function describeCommand(Command $command, array $options = []): void { - $this->writeData($this->getCommandData($command, $options['short'] ?? false), $options); + $this->writeData($this->getCommandData($command, $options), $options); } protected function describeApplication(Application $application, array $options = []): void @@ -56,7 +59,7 @@ protected function describeApplication(Application $application, array $options $commands = []; foreach ($description->getCommands() as $command) { - $commands[] = $this->getCommandData($command, $options['short'] ?? false); + $commands[] = $this->getCommandData($command, $options); } $data = []; @@ -101,26 +104,32 @@ private function getInputArgumentData(InputArgument $argument): array private function getInputOptionData(InputOption $option, bool $negated = false): array { - return $negated ? [ - 'name' => '--no-'.$option->getName(), + $data = $negated ? [ + 'name' => '--no-' . $option->getName(), 'shortcut' => '', 'accept_value' => false, 'is_value_required' => false, 'is_multiple' => false, - 'description' => 'Negate the "--'.$option->getName().'" option', + 'is_deprecated' => $option->isDeprecated(), + 'description' => 'Negate the "--' . $option->getName() . '" option', 'default' => false, ] : [ - 'name' => '--'.$option->getName(), - 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '', + 'name' => '--' . $option->getName(), + 'shortcut' => $option->getShortcut() ? '-' . str_replace('|', '|-', $option->getShortcut()) : '', 'accept_value' => $option->acceptValue(), 'is_value_required' => $option->isValueRequired(), 'is_multiple' => $option->isArray(), + 'is_deprecated' => $option->isDeprecated(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()), 'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault(), ]; + if (!$option->isDeprecated()) { + unset($data['is_deprecated']); + } + return $data; } - private function getInputDefinitionData(InputDefinition $definition): array + private function getInputDefinitionData(InputDefinition $definition, array $options): array { $inputArguments = []; foreach ($definition->getArguments() as $name => $argument) { @@ -128,7 +137,7 @@ private function getInputDefinitionData(InputDefinition $definition): array } $inputOptions = []; - foreach ($definition->getOptions() as $name => $option) { + foreach ($this->removeHiddenOptions($definition->getOptions(), $options) as $name => $option) { $inputOptions[$name] = $this->getInputOptionData($option); if ($option->isNegatable()) { $inputOptions['no-'.$name] = $this->getInputOptionData($option, true); @@ -138,8 +147,10 @@ private function getInputDefinitionData(InputDefinition $definition): array return ['arguments' => $inputArguments, 'options' => $inputOptions]; } - private function getCommandData(Command $command, bool $short = false): array + private function getCommandData(Command $command, array $options = []): array { + $short = $options['short'] ?? false; + $data = [ 'name' => $command->getName(), 'description' => $command->getDescription(), @@ -155,7 +166,7 @@ private function getCommandData(Command $command, bool $short = false): array $data += [ 'usage' => array_merge([$command->getSynopsis()], $command->getUsages(), $command->getAliases()), 'help' => $command->getProcessedHelp(), - 'definition' => $this->getInputDefinitionData($command->getDefinition()), + 'definition' => $this->getInputDefinitionData($command->getDefinition(), $options), ]; } diff --git a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php index 8b70759439aab..5b819ae394dfc 100644 --- a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php @@ -70,6 +70,7 @@ protected function describeInputOption(InputOption $option, array $options = []) .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n" .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n" .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n" + .($option->isDeprecated() ? ('* Is deprecated: yes'."\n") : '') .'* Is negatable: '.($option->isNegatable() ? 'yes' : 'no')."\n" .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`' ); @@ -81,19 +82,20 @@ protected function describeInputDefinition(InputDefinition $definition, array $o $this->write('### Arguments'); foreach ($definition->getArguments() as $argument) { $this->write("\n\n"); - $this->describeInputArgument($argument); + $this->describeInputArgument($argument, $options); } } - if (\count($definition->getOptions()) > 0) { + $inputOptions = $this->removeHiddenOptions($definition->getOptions(), $options); + if (!empty($inputOptions)) { if ($showArguments) { $this->write("\n\n"); } $this->write('### Options'); - foreach ($definition->getOptions() as $option) { + foreach ($inputOptions as $option) { $this->write("\n\n"); - $this->describeInputOption($option); + $this->describeInputOption($option, $options); } } } @@ -128,9 +130,9 @@ protected function describeCommand(Command $command, array $options = []): void } $definition = $command->getDefinition(); - if ($definition->getOptions() || $definition->getArguments()) { + if ($this->removeHiddenOptions($definition->getOptions(), $options) || $definition->getArguments()) { $this->write("\n\n"); - $this->describeInputDefinition($definition); + $this->describeInputDefinition($definition, $options); } } diff --git a/src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php b/src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php index cbf49d8799cdd..65e1bb27379ed 100644 --- a/src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php @@ -84,6 +84,7 @@ protected function describeInputOption(InputOption $option, array $options = []) .'- **Accept value**: '.($option->acceptValue() ? 'yes' : 'no')."\n" .'- **Is value required**: '.($option->isValueRequired() ? 'yes' : 'no')."\n" .'- **Is multiple**: '.($option->isArray() ? 'yes' : 'no')."\n" + .($option->isDeprecated() ? ('- **Is deprecated**: yes'."\n") : '') .'- **Is negatable**: '.($option->isNegatable() ? 'yes' : 'no')."\n" .'- **Default**: ``'.str_replace("\n", '', var_export($option->getDefault(), true)).'``'."\n" ); @@ -95,18 +96,19 @@ protected function describeInputDefinition(InputDefinition $definition, array $o $this->write("Arguments\n".str_repeat($this->subsubsectionChar, 9)); foreach ($definition->getArguments() as $argument) { $this->write("\n\n"); - $this->describeInputArgument($argument); + $this->describeInputArgument($argument, $options); } } - if ($nonDefaultOptions = $this->getNonDefaultOptions($definition)) { + $inputOptions = $this->removeHiddenOptions($this->getNonDefaultOptions($definition), $options); + if (!empty($inputOptions)) { if ($showArguments) { $this->write("\n\n"); } - $this->write("Options\n".str_repeat($this->subsubsectionChar, 7)."\n\n"); - foreach ($nonDefaultOptions as $option) { - $this->describeInputOption($option); + $this->write("Options\n" . str_repeat($this->subsubsectionChar, 7) . "\n\n"); + foreach ($inputOptions as $option) { + $this->describeInputOption($option, $options); $this->write("\n"); } } @@ -145,9 +147,9 @@ protected function describeCommand(Command $command, array $options = []): void } $definition = $command->getDefinition(); - if ($definition->getOptions() || $definition->getArguments()) { + if ($this->removeHiddenOptions($definition->getOptions(), $options) || $definition->getArguments()) { $this->write("\n\n"); - $this->describeInputDefinition($definition); + $this->describeInputDefinition($definition, $options); } } diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 51c411f4626da..fad5353664023 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -73,8 +73,8 @@ protected function describeInputOption(InputOption $option, array $options = []) $spacingWidth = $totalWidth - Helper::width($synopsis); - $this->writeText(\sprintf(' %s %s%s%s%s', - $synopsis, + $this->writeText(\sprintf(' %s %s%s%s%s', + \sprintf('<%1$s>%2$s', $option->isDeprecated() ? 'text_error' : 'info', $synopsis), str_repeat(' ', $spacingWidth), // + 4 = 2 spaces before , 2 spaces after preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()), @@ -85,29 +85,30 @@ protected function describeInputOption(InputOption $option, array $options = []) protected function describeInputDefinition(InputDefinition $definition, array $options = []): void { - $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions()); - foreach ($definition->getArguments() as $argument) { + $inputArguments = $definition->getArguments(); + $inputOptions = $this->removeHiddenOptions($definition->getOptions(), $options); + $totalWidth = $this->calculateTotalWidthForOptions($inputOptions); + foreach ($inputArguments as $argument) { $totalWidth = max($totalWidth, Helper::width($argument->getName())); } - if ($definition->getArguments()) { + if ($inputArguments) { $this->writeText('Arguments:', $options); $this->writeText("\n"); - foreach ($definition->getArguments() as $argument) { + foreach ($inputArguments as $argument) { $this->describeInputArgument($argument, array_merge($options, ['total_width' => $totalWidth])); $this->writeText("\n"); } } - if ($definition->getArguments() && $definition->getOptions()) { - $this->writeText("\n"); - } - - if ($definition->getOptions()) { + if ($inputOptions) { + if ($showArguments) { + $this->writeText("\n"); + } $laterOptions = []; $this->writeText('Options:', $options); - foreach ($definition->getOptions() as $option) { + foreach ($inputOptions as $option) { if (\strlen($option->getShortcut() ?? '') > 1) { $laterOptions[] = $option; continue; @@ -141,7 +142,7 @@ protected function describeCommand(Command $command, array $options = []): void $this->writeText("\n"); $definition = $command->getDefinition(); - if ($definition->getOptions() || $definition->getArguments()) { + if ($this->removeHiddenOptions($definition->getOptions(), $options) || $definition->getArguments()) { $this->writeText("\n"); $this->describeInputDefinition($definition, $options); $this->writeText("\n"); diff --git a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php index 00055557c467b..2b8a281315d3c 100644 --- a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php @@ -26,7 +26,7 @@ */ class XmlDescriptor extends Descriptor { - public function getInputDefinitionDocument(InputDefinition $definition): \DOMDocument + public function getInputDefinitionDocument(InputDefinition $definition, array $options = []): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($definitionXML = $dom->createElement('definition')); @@ -37,14 +37,14 @@ public function getInputDefinitionDocument(InputDefinition $definition): \DOMDoc } $definitionXML->appendChild($optionsXML = $dom->createElement('options')); - foreach ($definition->getOptions() as $option) { + foreach ($this->removeHiddenOptions($definition->getOptions(), $options) as $option) { $this->appendDocument($optionsXML, $this->getInputOptionDocument($option)); } return $dom; } - public function getCommandDocument(Command $command, bool $short = false): \DOMDocument + public function getCommandDocument(Command $command, bool $short = false, array $options = []): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($commandXML = $dom->createElement('command')); @@ -72,14 +72,14 @@ public function getCommandDocument(Command $command, bool $short = false): \DOMD $commandXML->appendChild($helpXML = $dom->createElement('help')); $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp()))); - $definitionXML = $this->getInputDefinitionDocument($command->getDefinition()); + $definitionXML = $this->getInputDefinitionDocument($command->getDefinition(), $options); $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0)); } return $dom; } - public function getApplicationDocument(Application $application, ?string $namespace = null, bool $short = false): \DOMDocument + public function getApplicationDocument(Application $application, ?string $namespace = null, bool $short = false, array $options = []): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($rootXml = $dom->createElement('symfony')); @@ -100,7 +100,7 @@ public function getApplicationDocument(Application $application, ?string $namesp } foreach ($description->getCommands() as $command) { - $this->appendDocument($commandsXML, $this->getCommandDocument($command, $short)); + $this->appendDocument($commandsXML, $this->getCommandDocument($command, $short, $options)); } if (!$namespace) { @@ -127,22 +127,25 @@ protected function describeInputArgument(InputArgument $argument, array $options protected function describeInputOption(InputOption $option, array $options = []): void { + if ($this->skipHiddenOption($option, $options)) { + return; + } $this->writeDocument($this->getInputOptionDocument($option)); } protected function describeInputDefinition(InputDefinition $definition, array $options = []): void { - $this->writeDocument($this->getInputDefinitionDocument($definition)); + $this->writeDocument($this->getInputDefinitionDocument($definition, $options)); } protected function describeCommand(Command $command, array $options = []): void { - $this->writeDocument($this->getCommandDocument($command, $options['short'] ?? false)); + $this->writeDocument($this->getCommandDocument($command, $options['short'] ?? false, $options)); } protected function describeApplication(Application $application, array $options = []): void { - $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null, $options['short'] ?? false)); + $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null, $options['short'] ?? false, $options)); } /** @@ -201,6 +204,9 @@ private function getInputOptionDocument(InputOption $option): \DOMDocument $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0); $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0); $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0); + if ($option->isDeprecated()) { + $objectXML->setAttribute('is_deprecated', 1); + } $objectXML->appendChild($descriptionXML = $dom->createElement('description')); $descriptionXML->appendChild($dom->createTextNode($option->getDescription())); @@ -221,6 +227,9 @@ private function getInputOptionDocument(InputOption $option): \DOMDocument $objectXML->setAttribute('accept_value', 0); $objectXML->setAttribute('is_value_required', 0); $objectXML->setAttribute('is_multiple', 0); + if ($option->isDeprecated()) { + $objectXML->setAttribute('is_deprecated', 1); + } $objectXML->appendChild($descriptionXML = $dom->createElement('description')); $descriptionXML->appendChild($dom->createTextNode('Negate the "--'.$option->getName().'" option')); } diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 3c8c287e8375f..97c2663120587 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -74,6 +74,7 @@ public function __construct( $this->setStyle('info', new OutputFormatterStyle('green')); $this->setStyle('comment', new OutputFormatterStyle('yellow')); $this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); + $this->setStyle('text_error', new OutputFormatterStyle('red')); foreach ($styles as $name => $style) { $this->setStyle($name, $style); diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index a8b006d484dbf..0b7579c43a06d 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -362,6 +362,9 @@ public function getSynopsis(bool $short = false): string $elements[] = '[options]'; } elseif (!$short) { foreach ($this->getOptions() as $option) { + if ($option->isHidden()) { + continue; + } $value = ''; if ($option->acceptValue()) { $value = \sprintf( diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 25fb917822815..e011b571c39b7 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -50,6 +50,22 @@ class InputOption */ public const VALUE_NEGATABLE = 16; + /** + * The option allows to deprecate command option. + * Option will be marked as deprecated in help output and a warning is printed when the command is executed. + */ + public const DEPRECATED = 32; + + /** + * The option allows to hide command option from help. + */ + public const HIDDEN = 64; + + /** + * The largest mode flag defined to validate mode limits. + */ + private const LARGEST_MODE_FLAG = self::HIDDEN; + private string $name; private ?string $shortcut; private int $mode; @@ -98,7 +114,7 @@ public function __construct( if (null === $mode) { $mode = self::VALUE_NONE; - } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) { + } elseif ($mode >= (self::LARGEST_MODE_FLAG << 1) || $mode < 1) { throw new InvalidArgumentException(\sprintf('Option mode "%s" is not valid.', $mode)); } @@ -152,7 +168,7 @@ public function acceptValue(): bool */ public function isValueRequired(): bool { - return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode); + return $this->hastMode(self::VALUE_REQUIRED); } /** @@ -162,7 +178,7 @@ public function isValueRequired(): bool */ public function isValueOptional(): bool { - return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode); + return $this->hastMode(self::VALUE_OPTIONAL); } /** @@ -172,7 +188,27 @@ public function isValueOptional(): bool */ public function isArray(): bool { - return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); + return $this->hastMode(self::VALUE_IS_ARRAY); + } + + /** + * Returns true if the option is deprecated. + * + * @return bool true if mode is self::DEPRECATED, false otherwise + */ + public function isDeprecated():bool + { + return $this->hastMode(self::DEPRECATED); + } + + /** + * Returns true if the option is hidden. + * + * @return bool true if mode is self::HIDDEN, false otherwise + */ + public function isHidden():bool + { + return $this->hastMode(self::HIDDEN); } /** @@ -182,7 +218,7 @@ public function isArray(): bool */ public function isNegatable(): bool { - return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode); + return $this->hastMode(self::VALUE_NEGATABLE); } /** @@ -259,4 +295,14 @@ public function equals(self $option): bool && $option->isValueOptional() === $this->isValueOptional() ; } + + /** + * Returns true if the option allows $mode. + * + * @return bool true if mode is $mode, false otherwise + */ + protected function hastMode(int $mode): bool + { + return $mode === ($mode & $this->mode); + } } diff --git a/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php b/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php index df0d081fd9acb..ed6463252cd52 100644 --- a/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php +++ b/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php @@ -28,6 +28,8 @@ public function testBind(CompletionInput $input, string $expectedType, ?string $ new InputOption('with-required-value', 'r', InputOption::VALUE_REQUIRED), new InputOption('with-optional-value', 'o', InputOption::VALUE_OPTIONAL), new InputOption('without-value', 'n', InputOption::VALUE_NONE), + new InputOption('deprecated-option', 'y', InputOption::DEPRECATED | InputOption::VALUE_NONE), + new InputOption('hidden-option', 'z', InputOption::HIDDEN | InputOption::VALUE_NONE), new InputArgument('required-arg', InputArgument::REQUIRED), new InputArgument('optional-arg', InputArgument::OPTIONAL), ]); @@ -61,6 +63,14 @@ public static function provideBindData() yield 'optval-long-optional' => [CompletionInput::fromTokens(['bin/console', '--with-optional-value='], 1), CompletionInput::TYPE_OPTION_VALUE, 'with-optional-value', '']; yield 'optval-long-space-optional' => [CompletionInput::fromTokens(['bin/console', '--with-optional-value'], 2), CompletionInput::TYPE_OPTION_VALUE, 'with-optional-value', '']; + // deprecated & hidden options + yield 'optval-short-deprecated' => [CompletionInput::fromTokens(['bin/console', '-y'], 2), CompletionInput::TYPE_ARGUMENT_VALUE, 'required-arg', '']; + yield 'optval-short-hidden' => [CompletionInput::fromTokens(['bin/console', '-z'], 2), CompletionInput::TYPE_ARGUMENT_VALUE, 'required-arg', '']; + yield 'optval-long-deprecated-partial' => [CompletionInput::fromTokens(['bin/console', '--deprecated'], 1), CompletionInput::TYPE_OPTION_NAME, null, '--deprecated']; + yield 'optval-long-deprecated' => [CompletionInput::fromTokens(['bin/console', '--deprecated-option'], 2), CompletionInput::TYPE_ARGUMENT_VALUE, 'required-arg', '']; + yield 'optval-long-hidden-partial' => [CompletionInput::fromTokens(['bin/console', '--hidden'], 1), CompletionInput::TYPE_OPTION_NAME, null, '--hidden']; + yield 'optval-long-hidden' => [CompletionInput::fromTokens(['bin/console', '--hidden-option'], 2), CompletionInput::TYPE_ARGUMENT_VALUE, 'required-arg', '']; + // arguments yield 'arg-minimal-input' => [CompletionInput::fromTokens(['bin/console'], 1), CompletionInput::TYPE_ARGUMENT_VALUE, 'required-arg', '']; yield 'arg-optional' => [CompletionInput::fromTokens(['bin/console', 'symfony'], 2), CompletionInput::TYPE_ARGUMENT_VALUE, 'optional-arg', '']; diff --git a/src/Symfony/Component/Console/Tests/Completion/Output/CompletionOutputTestCase.php b/src/Symfony/Component/Console/Tests/Completion/Output/CompletionOutputTestCase.php index 3ca7c15db9b60..22d49fdee900d 100644 --- a/src/Symfony/Component/Console/Tests/Completion/Output/CompletionOutputTestCase.php +++ b/src/Symfony/Component/Console/Tests/Completion/Output/CompletionOutputTestCase.php @@ -30,6 +30,7 @@ public function testOptionsOutput() { $options = [ new InputOption('option1', 'o', InputOption::VALUE_NONE, 'First Option'), + new InputOption('hidden', 'o', InputOption::HIDDEN, 'Hidden Option'), new InputOption('negatable', null, InputOption::VALUE_NEGATABLE, 'Can be negative'), ]; $suggestions = new CompletionSuggestions(); diff --git a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php index 93658f4beca4d..adfbac28db84b 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php @@ -18,6 +18,7 @@ use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand5; abstract class AbstractDescriptorTestCase extends TestCase { @@ -45,6 +46,13 @@ public function testDescribeCommand(Command $command, $expectedDescription) $this->assertDescription($expectedDescription, $command); } + public function testDescribeCommandWithHiddenOptions() + { + [$command, $expectedDescription] = static::getDescriptionTestData(['command_5_with_hidden_options' => new DescriptorCommand5()])[0]; + + $this->assertDescription($expectedDescription, $command, ['show-hidden-options' =>true]); + } + /** @dataProvider getDescribeApplicationTestData */ public function testDescribeApplication(Application $application, $expectedDescription) { diff --git a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php index 399bd8f2368db..cb383032d257e 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php @@ -27,7 +27,10 @@ protected static function getFormat() protected function normalizeOutput($output) { - return array_map($this->normalizeOutputRecursively(...), json_decode($output, true)); + if (null === $output || !is_array($output = json_decode($output, true))) { + return $output; + } + return array_map($this->normalizeOutputRecursively(...), $output); } private function normalizeOutputRecursively($output) diff --git a/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php b/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php index ccd4c3b071319..e4585043ceb51 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php @@ -18,6 +18,7 @@ use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication2; use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand1; use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand2; +use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand5; /** * @author Jean-François Simon @@ -45,6 +46,8 @@ public static function getInputOptions() 'input_option_4' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'option description', []), 'input_option_5' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, "multiline\noption description"), 'input_option_6' => new InputOption('option_name', ['o', 'O'], InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'), + 'input_option_deprecated' => new InputOption('option_name', 'o', InputOption::DEPRECATED, 'deprecated option description'), + 'input_option_hidden' => new InputOption('option_name', 'o', InputOption::HIDDEN, 'hidden option description'), 'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', 'style'), 'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', ['Hello', 'world']), 'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', \INF), @@ -69,6 +72,7 @@ public static function getCommands() return [ 'command_1' => new DescriptorCommand1(), 'command_2' => new DescriptorCommand2(), + 'command_5' => new DescriptorCommand5(), ]; } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php index 7bb02fa54c1ff..497cba816d0bc 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php @@ -22,5 +22,6 @@ public function __construct() $this->add(new DescriptorCommand2()); $this->add(new DescriptorCommand3()); $this->add(new DescriptorCommand4()); + $this->add(new DescriptorCommand5()); } } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand5.php b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand5.php new file mode 100644 index 0000000000000..464631a94d82c --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand5.php @@ -0,0 +1,27 @@ +setName('descriptor:command5') + ->setDescription('command 5 description') + ->setHelp('command 5 help') + ->addOption('deprecated_option', 'y', InputOption::DEPRECATED) + ->addOption('hidden_option', 'z', InputOption::HIDDEN) + ; + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.json b/src/Symfony/Component/Console/Tests/Fixtures/application_2.json index b3eb10bda3d63..5659041fc222c 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.json +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.json @@ -765,6 +765,93 @@ } } } + }, + { + "name": "descriptor:command5", + "hidden": false, + "usage": [ + "descriptor:command5 [-y|--deprecated_option]" + ], + "description": "command 5 description", + "help": "command 5 help", + "definition": { + "arguments": {}, + "options": { + "help": { + "name": "--help", + "shortcut": "-h", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "Display help for the given command. When no command is given display help for the list command", + "default": false + }, + "quiet": { + "name": "--quiet", + "shortcut": "-q", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "Do not output any message", + "default": false + }, + "verbose": { + "name": "--verbose", + "shortcut": "-v|-vv|-vvv", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug", + "default": false + }, + "version": { + "name": "--version", + "shortcut": "-V", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "Display this application version", + "default": false + }, + "ansi": { + "name": "--ansi", + "shortcut": "", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "Force (or disable --no-ansi) ANSI output", + "default": null + }, + "no-ansi": { + "name": "--no-ansi", + "shortcut": "", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "Negate the \"--ansi\" option", + "default": null + }, + "no-interaction": { + "name": "--no-interaction", + "shortcut": "-n", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "Do not ask any interactive question", + "default": false + }, + "deprecated_option": { + "name": "--deprecated_option", + "shortcut": "-y", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "", + "default": false, + "is_deprecated": true + } + } + } } ], "namespaces": [ @@ -792,7 +879,8 @@ "descriptor:command1", "descriptor:command2", "descriptor:command3", - "descriptor:command4" + "descriptor:command4", + "descriptor:command5" ] } ] diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.md b/src/Symfony/Component/Console/Tests/Fixtures/application_2.md index d4802c7470937..2f1d0218a2aa0 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.md +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.md @@ -17,6 +17,7 @@ My Symfony application v1.0 * [`descriptor:command1`](#descriptorcommand1) * [`descriptor:command2`](#descriptorcommand2) * [`descriptor:command4`](#descriptorcommand4) +* [`descriptor:command5`](#descriptorcommand5) `completion` ------------ @@ -586,3 +587,85 @@ Do not ask any interactive question * Is multiple: no * Is negatable: no * Default: `false` + +`descriptor:command5` +--------------------- + +command 5 description + +### Usage + +* `descriptor:command5 [-y|--deprecated_option]` + +command 5 help + +### Options + +#### `--deprecated_option|-y` + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is deprecated: yes +* Is negatable: no +* Default: `false` + +#### `--help|-h` + +Display help for the given command. When no command is given display help for the list command + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is negatable: no +* Default: `false` + +#### `--quiet|-q` + +Do not output any message + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is negatable: no +* Default: `false` + +#### `--verbose|-v|-vv|-vvv` + +Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is negatable: no +* Default: `false` + +#### `--version|-V` + +Display this application version + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is negatable: no +* Default: `false` + +#### `--ansi|--no-ansi` + +Force (or disable --no-ansi) ANSI output + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is negatable: yes +* Default: `NULL` + +#### `--no-interaction|-n` + +Do not ask any interactive question + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is negatable: no +* Default: `false` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.rst b/src/Symfony/Component/Console/Tests/Fixtures/application_2.rst index 6426b62bd0428..951b10dfa7910 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.rst +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.rst @@ -17,6 +17,7 @@ descriptor - `descriptor:command1`_ - `descriptor:command2`_ - `descriptor:command4`_ +- `descriptor:command5`_ Commands -------- @@ -214,3 +215,31 @@ Usage - ``descriptor:command4`` - ``descriptor:alias_command4`` - ``command4:descriptor`` + + + + +descriptor:command5 +................... + +command 5 description + +Usage +^^^^^ + +- ``descriptor:command5 [-y|--deprecated_option]`` + +command 5 help + +Options +^^^^^^^ + +\-\-deprecated_option|-y +"""""""""""""""""""""""" + +- **Accept value**: no +- **Is value required**: no +- **Is multiple**: no +- **Is deprecated**: yes +- **Is negatable**: no +- **Default**: ``false`` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_2.txt index aed535fa4eca9..96cb22573b928 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.txt @@ -18,4 +18,5 @@ My Symfony application v1.0 descriptor descriptor:command1 [alias1|alias2] command 1 description descriptor:command2 command 2 description - descriptor:command4 [descriptor:alias_command4|command4:descriptor] + descriptor:command4 [descriptor:alias_command4|command4:descriptor] + descriptor:command5 command 5 description diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.xml b/src/Symfony/Component/Console/Tests/Fixtures/application_2.xml index 6ee45c1fabf4d..af75f305ba067 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.xml +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.xml @@ -346,6 +346,40 @@ + @@ -365,6 +399,7 @@ descriptor:command2 descriptor:command3 descriptor:command4 + descriptor:command5 diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5.json b/src/Symfony/Component/Console/Tests/Fixtures/command_5.json new file mode 100644 index 0000000000000..e8b2482a59742 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5.json @@ -0,0 +1,25 @@ +{ + "name": "descriptor:command5", + "hidden": false, + "usage": [ + "descriptor:command5 [-y|--deprecated_option]" + ], + "description": "command 5 description", + "help": "command 5 help", + "definition": { + "arguments": { + }, + "options": { + "deprecated_option": { + "name": "--deprecated_option", + "shortcut": "-y", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "", + "default": false, + "is_deprecated": true + } + } + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5.md b/src/Symfony/Component/Console/Tests/Fixtures/command_5.md new file mode 100644 index 0000000000000..955c944eddd5b --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5.md @@ -0,0 +1,21 @@ +`descriptor:command5` +--------------------- + +command 5 description + +### Usage + +* `descriptor:command5 [-y|--deprecated_option]` + +command 5 help + +### Options + +#### `--deprecated_option|-y` + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is deprecated: yes +* Is negatable: no +* Default: `false` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5.rst b/src/Symfony/Component/Console/Tests/Fixtures/command_5.rst new file mode 100644 index 0000000000000..10926eb330d16 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5.rst @@ -0,0 +1,24 @@ +descriptor:command5 +................... + +command 5 description + +Usage +^^^^^ + +- ``descriptor:command5 [-y|--deprecated_option]`` + +command 5 help + +Options +^^^^^^^ + +\-\-deprecated_option|-y +"""""""""""""""""""""""" + +- **Accept value**: no +- **Is value required**: no +- **Is multiple**: no +- **Is deprecated**: yes +- **Is negatable**: no +- **Default**: ``false`` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt new file mode 100644 index 0000000000000..b1f51aa617ac9 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt @@ -0,0 +1,11 @@ +Description: + command 5 description + +Usage: + descriptor:command5 [options] + +Options: + -y, --deprecated_option + +Help: + command 5 help diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5.xml b/src/Symfony/Component/Console/Tests/Fixtures/command_5.xml new file mode 100644 index 0000000000000..9a6923a14f899 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5.xml @@ -0,0 +1,14 @@ + + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.json b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.json new file mode 100644 index 0000000000000..d7618e54de6c7 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.json @@ -0,0 +1,34 @@ +{ + "name": "descriptor:command5", + "hidden": false, + "usage": [ + "descriptor:command5 [-y|--deprecated_option]" + ], + "description": "command 5 description", + "help": "command 5 help", + "definition": { + "arguments": { + }, + "options": { + "deprecated_option": { + "name": "--deprecated_option", + "shortcut": "-y", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "", + "default": false, + "is_deprecated": true + }, + "hidden_option": { + "name": "--hidden_option", + "shortcut": "-z", + "accept_value": false, + "is_value_required": false, + "is_multiple": false, + "description": "", + "default": false + } + } + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.md b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.md new file mode 100644 index 0000000000000..9c8ce3d7476b8 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.md @@ -0,0 +1,29 @@ +`descriptor:command5` +--------------------- + +command 5 description + +### Usage + +* `descriptor:command5 [-y|--deprecated_option]` + +command 5 help + +### Options + +#### `--deprecated_option|-y` + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is deprecated: yes +* Is negatable: no +* Default: `false` + +#### `--hidden_option|-z` + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is negatable: no +* Default: `false` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.rst b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.rst new file mode 100644 index 0000000000000..03383185d7bb6 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.rst @@ -0,0 +1,33 @@ +descriptor:command5 +................... + +command 5 description + +Usage +^^^^^ + +- ``descriptor:command5 [-y|--deprecated_option]`` + +command 5 help + +Options +^^^^^^^ + +\-\-deprecated_option|-y +"""""""""""""""""""""""" + +- **Accept value**: no +- **Is value required**: no +- **Is multiple**: no +- **Is deprecated**: yes +- **Is negatable**: no +- **Default**: ``false`` + +\-\-hidden_option|-z +"""""""""""""""""""" + +- **Accept value**: no +- **Is value required**: no +- **Is multiple**: no +- **Is negatable**: no +- **Default**: ``false`` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt new file mode 100644 index 0000000000000..f24946e0d375d --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt @@ -0,0 +1,12 @@ +Description: + command 5 description + +Usage: + descriptor:command5 [options] + +Options: + -y, --deprecated_option + -z, --hidden_option + +Help: + command 5 help diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.xml b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.xml new file mode 100644 index 0000000000000..e9779fde6b7f6 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.xml @@ -0,0 +1,17 @@ + + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.json b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.json new file mode 100644 index 0000000000000..b16247529ec61 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.json @@ -0,0 +1,10 @@ +{ + "name": "--option_name", + "shortcut": "-o", + "accept_value": "", + "is_value_required": "", + "is_multiple": "", + "is_deprecated": "1", + "description": "deprecated option description", + "default": "" +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.md b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.md new file mode 100644 index 0000000000000..42ab09d875dbd --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.md @@ -0,0 +1,10 @@ +#### `--option_name|-o` + +deprecated option description + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is deprecated: yes +* Is negatable: no +* Default: `false` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.rst b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.rst new file mode 100644 index 0000000000000..a984ab0041cba --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.rst @@ -0,0 +1,12 @@ +\-\-option_name|-o +"""""""""""""""""" + +deprecated option description + +- **Accept value**: no +- **Is value required**: no +- **Is multiple**: no +- **Is deprecated**: yes +- **Is negatable**: no +- **Default**: ``false`` + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt new file mode 100644 index 0000000000000..bfc1a40f6f432 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt @@ -0,0 +1 @@ +-o, --option_name deprecated option description diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.xml b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.xml new file mode 100644 index 0000000000000..4d23bae49fc6e --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.xml @@ -0,0 +1,4 @@ + + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.json b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.json new file mode 100644 index 0000000000000..7951defec192a --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.json @@ -0,0 +1 @@ +NULL diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.md b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.md new file mode 100644 index 0000000000000..93706145b92ac --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.md @@ -0,0 +1,9 @@ +#### `--option_name|-o` + +hidden option description + +* Accept value: no +* Is value required: no +* Is multiple: no +* Is negatable: no +* Default: `false` diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.rst b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.rst new file mode 100644 index 0000000000000..694bf1ac5099f --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.rst @@ -0,0 +1,11 @@ +\-\-option_name|-o +"""""""""""""""""" + +hidden option description + +- **Accept value**: no +- **Is value required**: no +- **Is multiple**: no +- **Is negatable**: no +- **Default**: ``false`` + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.txt b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.txt new file mode 100644 index 0000000000000..d581e40db1b72 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.txt @@ -0,0 +1 @@ +-o, --option_name hidden option description diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.xml b/src/Symfony/Component/Console/Tests/Fixtures/input_option_hidden.xml new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index f62fa088907d3..655624f60dd9d 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -51,6 +51,7 @@ public function testBundledStyles() $this->assertTrue($formatter->hasStyle('info')); $this->assertTrue($formatter->hasStyle('comment')); $this->assertTrue($formatter->hasStyle('question')); + $this->assertTrue($formatter->hasStyle('text_error')); $this->assertEquals( "\033[37;41msome error\033[39;49m", @@ -68,6 +69,10 @@ public function testBundledStyles() "\033[30;46msome question\033[39;49m", $formatter->format('some question') ); + $this->assertEquals( + "\033[31msome text_error\033[39m", + $formatter->format('some text_error') + ); } public function testNestedStyles() @@ -236,6 +241,7 @@ public function testFormatterHasStyles() $formatter = new OutputFormatter(false); $this->assertTrue($formatter->hasStyle('error')); + $this->assertTrue($formatter->hasStyle('text_error')); $this->assertTrue($formatter->hasStyle('info')); $this->assertTrue($formatter->hasStyle('comment')); $this->assertTrue($formatter->hasStyle('question')); @@ -292,6 +298,7 @@ public static function provideDecoratedAndNonDecoratedOutput() { return [ ['some error', 'some error', "\033[37;41msome error\033[39;49m"], + ['some error', 'some error', "\033[31msome error\033[39m"], ['some info', 'some info', "\033[32msome info\033[39m"], ['some comment', 'some comment', "\033[33msome comment\033[39m"], ['some question', 'some question', "\033[30;46msome question\033[39;49m"], diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php index a3fd3e2ea519c..524cddc6fb94c 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -20,11 +20,11 @@ class InputDefinitionTest extends TestCase { protected static string $fixtures; - protected $multi; - protected $foo; - protected $bar; - protected $foo1; - protected $foo2; + protected InputArgument|InputOption|null $multi; + protected InputArgument|InputOption|null $foo; + protected InputArgument|InputOption|null $bar; + protected InputArgument|InputOption|null $foo1; + protected InputArgument|InputOption|null $foo2; public static function setUpBeforeClass(): void { @@ -362,7 +362,7 @@ public function testGetOptionDefaults() /** * @dataProvider getGetSynopsisData */ - public function testGetSynopsis(InputDefinition $definition, $expectedSynopsis, $message = null) + public function testGetSynopsis(InputDefinition $definition, ?string $expectedSynopsis, ?string $message = null) { $this->assertEquals($expectedSynopsis, $definition->getSynopsis(), $message ? '->getSynopsis() '.$message : ''); } @@ -382,12 +382,28 @@ public static function getGetSynopsisData() [new InputDefinition([new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY)]), '...', 'uses an ellipsis for required array arguments'], [new InputDefinition([new InputOption('foo'), new InputArgument('foo', InputArgument::REQUIRED)]), '[--foo] [--] ', 'puts [--] between options and arguments'], + + [new InputDefinition([new InputOption('deprecated', null, InputOption::DEPRECATED)]), '[--deprecated]', 'puts deprecated optional options in square brackets'], + [ + new InputDefinition([new InputOption('foo'), new InputOption('deprecated', null, InputOption::DEPRECATED)]), + '[--foo] [--deprecated]', + 'puts deprecated optional options in square brackets' + ], + + [new InputDefinition([new InputOption('hidden', null, InputOption::HIDDEN)]), '', 'hidden option is not visible'], + [new InputDefinition([new InputOption('foo'), new InputOption('hidden', null, InputOption::HIDDEN)]), '[--foo]', 'hidden option is not visible'], ]; } public function testGetShortSynopsis() { - $definition = new InputDefinition([new InputOption('foo'), new InputOption('bar'), new InputArgument('cat')]); + $definition = new InputDefinition([ + new InputOption('foo'), + new InputOption('bar'), + new InputOption('deprecated'), + new InputOption('hidden'), + new InputArgument('cat') + ]); $this->assertEquals('[options] [--] []', $definition->getSynopsis(true), '->getSynopsis(true) groups options in [options]'); } diff --git a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php index 7e3fb16da1fe9..e70a8caf60223 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -83,34 +83,67 @@ public function testModes() $this->assertFalse($option->acceptValue(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); $this->assertFalse($option->isValueRequired(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); $this->assertFalse($option->isValueOptional(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); + $this->assertFalse($option->isDeprecated(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isHidden(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); $option = new InputOption('foo', 'f', null); $this->assertFalse($option->acceptValue(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); $this->assertFalse($option->isValueOptional(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isDeprecated(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isHidden(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); $option = new InputOption('foo', 'f', InputOption::VALUE_NONE); $this->assertFalse($option->acceptValue(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); $this->assertFalse($option->isValueOptional(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isDeprecated(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isHidden(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); $option = new InputOption('foo', 'f', InputOption::VALUE_REQUIRED); $this->assertTrue($option->acceptValue(), '__construct() can take "InputOption::VALUE_REQUIRED" as its mode'); $this->assertTrue($option->isValueRequired(), '__construct() can take "InputOption::VALUE_REQUIRED" as its mode'); $this->assertFalse($option->isValueOptional(), '__construct() can take "InputOption::VALUE_REQUIRED" as its mode'); + $this->assertFalse($option->isDeprecated(), '__construct() can take "InputOption::VALUE_REQUIRED" as its mode'); + $this->assertFalse($option->isHidden(), '__construct() can take "InputOption::VALUE_REQUIRED" as its mode'); $option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL); $this->assertTrue($option->acceptValue(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); $this->assertTrue($option->isValueOptional(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); + $this->assertFalse($option->isDeprecated(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); + $this->assertFalse($option->isHidden(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); + + $option = new InputOption('foo', 'f', InputOption::DEPRECATED); + $this->assertFalse($option->acceptValue(), '__construct() can take "InputOption::DEPRECATED" as its mode'); + $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::DEPRECATED" as its mode'); + $this->assertFalse($option->isValueOptional(), '__construct() can take "InputOption::DEPRECATED" as its mode'); + $this->assertTrue($option->isDeprecated(), '__construct() can take "InputOption::HIDDEN" as its mode'); + $this->assertFalse($option->isHidden(), '__construct() can take "InputOption::HIDDEN" as its mode'); + + $option = new InputOption('foo', 'f', InputOption::HIDDEN); + $this->assertFalse($option->acceptValue(), '__construct() can take "InputOption::HIDDEN" as its mode'); + $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::HIDDEN" as its mode'); + $this->assertFalse($option->isValueOptional(), '__construct() can take "InputOption::HIDDEN" as its mode'); + $this->assertFalse($option->isDeprecated(), '__construct() can take "InputOption::HIDDEN" as its mode'); + $this->assertTrue($option->isHidden(), '__construct() can take "InputOption::HIDDEN" as its mode'); } - public function testInvalidModes() + /** + * @dataProvider privideInvalidModeData + */ + public function testInvalidMode(?int $mode, string $message) { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Option mode "-1" is not valid.'); + $this->expectExceptionMessage($message); - new InputOption('foo', 'f', '-1'); + new InputOption('foo', 'f', $mode); + } + + public static function privideInvalidModeData() + { + yield 'negative mode' => [-1, 'Option mode "-1" is not valid.']; + yield 'invalid bit mask value' => [InputOption::HIDDEN << 1, sprintf('Option mode "%d" is not valid.', InputOption::HIDDEN << 1)]; } public function testEmptyNameIsInvalid() From d203a4e938c7a59a90685b7cbea90dac61e6286b Mon Sep 17 00:00:00 2001 From: flkasper Date: Fri, 29 Mar 2024 19:45:02 +0100 Subject: [PATCH 02/15] Fix code style --- .../Console/Completion/CompletionInput.php | 2 + .../Console/Descriptor/Descriptor.php | 4 +- .../Console/Descriptor/JsonDescriptor.php | 9 +- .../Descriptor/ReStructuredTextDescriptor.php | 2 +- .../Console/Helper/QuestionHelper.php | 2 +- .../Component/Console/Input/InputOption.php | 4 +- .../Descriptor/AbstractDescriptorTestCase.php | 2 +- .../Tests/Descriptor/JsonDescriptorTest.php | 3 +- .../Console/Tests/Fixtures/BarBucCommand.php | 9 + .../Tests/Fixtures/BarHiddenCommand.php | 9 + .../Tests/Fixtures/DescriptorCommand5.php | 2 + .../Console/Tests/Fixtures/Foo1Command.php | 9 + .../Console/Tests/Fixtures/Foo2Command.php | 9 + .../Console/Tests/Fixtures/Foo3Command.php | 19 +- .../Console/Tests/Fixtures/Foo4Command.php | 9 + .../Console/Tests/Fixtures/Foo5Command.php | 9 + .../Console/Tests/Fixtures/Foo6Command.php | 9 + .../Console/Tests/Fixtures/FooCommand.php | 9 + .../Tests/Fixtures/FooHiddenCommand.php | 9 + .../Tests/Fixtures/FooLock2Command.php | 9 + .../Tests/Fixtures/FooLock3Command.php | 9 + .../Console/Tests/Fixtures/FooLockCommand.php | 9 + .../Console/Tests/Fixtures/FooOptCommand.php | 9 + .../Fixtures/FooSameCaseLowercaseCommand.php | 9 + .../Fixtures/FooSameCaseUppercaseCommand.php | 9 + .../Fixtures/FooSubnamespaced1Command.php | 9 + .../Fixtures/FooSubnamespaced2Command.php | 9 + .../Tests/Fixtures/FooWithoutAliasCommand.php | 9 + .../Console/Tests/Fixtures/FoobarCommand.php | 9 + .../Style/SymfonyStyle/command/command_0.php | 11 +- .../Style/SymfonyStyle/command/command_1.php | 11 +- .../Style/SymfonyStyle/command/command_10.php | 11 +- .../Style/SymfonyStyle/command/command_11.php | 9 + .../Style/SymfonyStyle/command/command_12.php | 9 + .../Style/SymfonyStyle/command/command_13.php | 9 + .../Style/SymfonyStyle/command/command_14.php | 9 + .../Style/SymfonyStyle/command/command_15.php | 9 + .../Style/SymfonyStyle/command/command_16.php | 9 + .../Style/SymfonyStyle/command/command_17.php | 11 +- .../Style/SymfonyStyle/command/command_18.php | 9 + .../Style/SymfonyStyle/command/command_19.php | 11 +- .../Style/SymfonyStyle/command/command_2.php | 11 +- .../Style/SymfonyStyle/command/command_20.php | 9 + .../Style/SymfonyStyle/command/command_21.php | 11 +- .../Style/SymfonyStyle/command/command_22.php | 9 + .../Style/SymfonyStyle/command/command_23.php | 9 + .../Style/SymfonyStyle/command/command_3.php | 11 +- .../Style/SymfonyStyle/command/command_4.php | 19 +- .../command/command_4_with_iterators.php | 21 +- .../Style/SymfonyStyle/command/command_5.php | 13 +- .../Style/SymfonyStyle/command/command_6.php | 11 +- .../Style/SymfonyStyle/command/command_7.php | 11 +- .../Style/SymfonyStyle/command/command_8.php | 11 +- .../Style/SymfonyStyle/command/command_9.php | 11 +- .../command/interactive_command_1.php | 11 +- .../progress/command_progress_iterate.php | 11 +- .../TestAmbiguousCommandRegistering.php | 9 + .../TestAmbiguousCommandRegistering2.php | 9 + .../Console/Tests/Fixtures/TestCommand.php | 9 + .../Tests/Fixtures/application_signalable.php | 15 +- .../Console/Tests/Helper/TableTest.php | 382 +++++++++--------- .../Tests/Input/InputDefinitionTest.php | 4 +- 62 files changed, 706 insertions(+), 239 deletions(-) diff --git a/src/Symfony/Component/Console/Completion/CompletionInput.php b/src/Symfony/Component/Console/Completion/CompletionInput.php index f6f040141907b..febe907702dff 100644 --- a/src/Symfony/Component/Console/Completion/CompletionInput.php +++ b/src/Symfony/Component/Console/Completion/CompletionInput.php @@ -201,6 +201,7 @@ private function getOptionFromToken(string $optionToken): ?InputOption if ($this->definition->hasOption($optionName) && !$this->definition->getOption($optionName)->isHidden()) { return $this->definition->getOption($optionName); } + return null; } @@ -208,6 +209,7 @@ private function getOptionFromToken(string $optionToken): ?InputOption if ($this->definition->hasShortcut($optionName[0]) && !$this->definition->getOptionForShortcut($optionName[0])->isHidden()) { return $this->definition->getOptionForShortcut($optionName[0]); } + return null; } diff --git a/src/Symfony/Component/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Console/Descriptor/Descriptor.php index 16cfacae7edeb..1be53134d2cb7 100644 --- a/src/Symfony/Component/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Console/Descriptor/Descriptor.php @@ -44,12 +44,14 @@ public function describe(OutputInterface $output, object $object, array $options /** * Filter hidden options from list. + * * @param array $inputOptions + * * @return array */ protected function removeHiddenOptions(array $inputOptions, array $options = []): array { - return array_filter($inputOptions, fn(InputOption $option) => !$this->skipHiddenOption($option, $options)); + return array_filter($inputOptions, fn (InputOption $option) => !$this->skipHiddenOption($option, $options)); } /** diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index 36e96d669fd4c..555c1afdc0362 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -105,17 +105,17 @@ private function getInputArgumentData(InputArgument $argument): array private function getInputOptionData(InputOption $option, bool $negated = false): array { $data = $negated ? [ - 'name' => '--no-' . $option->getName(), + 'name' => '--no-'.$option->getName(), 'shortcut' => '', 'accept_value' => false, 'is_value_required' => false, 'is_multiple' => false, 'is_deprecated' => $option->isDeprecated(), - 'description' => 'Negate the "--' . $option->getName() . '" option', + 'description' => 'Negate the "--'.$option->getName().'" option', 'default' => false, ] : [ - 'name' => '--' . $option->getName(), - 'shortcut' => $option->getShortcut() ? '-' . str_replace('|', '|-', $option->getShortcut()) : '', + 'name' => '--'.$option->getName(), + 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '', 'accept_value' => $option->acceptValue(), 'is_value_required' => $option->isValueRequired(), 'is_multiple' => $option->isArray(), @@ -126,6 +126,7 @@ private function getInputOptionData(InputOption $option, bool $negated = false): if (!$option->isDeprecated()) { unset($data['is_deprecated']); } + return $data; } diff --git a/src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php b/src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php index 65e1bb27379ed..81add6e99913b 100644 --- a/src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php @@ -106,7 +106,7 @@ protected function describeInputDefinition(InputDefinition $definition, array $o $this->write("\n\n"); } - $this->write("Options\n" . str_repeat($this->subsubsectionChar, 7) . "\n\n"); + $this->write("Options\n".str_repeat($this->subsubsectionChar, 7)."\n\n"); foreach ($inputOptions as $option) { $this->describeInputOption($option, $options); $this->write("\n"); diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 69afc2a67946f..8e1591ec1b14a 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -55,7 +55,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu } $inputStream = $input instanceof StreamableInputInterface ? $input->getStream() : null; - $inputStream ??= STDIN; + $inputStream ??= \STDIN; try { if (!$question->getValidator()) { diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index e011b571c39b7..24c56536a941a 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -196,7 +196,7 @@ public function isArray(): bool * * @return bool true if mode is self::DEPRECATED, false otherwise */ - public function isDeprecated():bool + public function isDeprecated(): bool { return $this->hastMode(self::DEPRECATED); } @@ -206,7 +206,7 @@ public function isDeprecated():bool * * @return bool true if mode is self::HIDDEN, false otherwise */ - public function isHidden():bool + public function isHidden(): bool { return $this->hastMode(self::HIDDEN); } diff --git a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php index adfbac28db84b..137c11ee62014 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php @@ -50,7 +50,7 @@ public function testDescribeCommandWithHiddenOptions() { [$command, $expectedDescription] = static::getDescriptionTestData(['command_5_with_hidden_options' => new DescriptorCommand5()])[0]; - $this->assertDescription($expectedDescription, $command, ['show-hidden-options' =>true]); + $this->assertDescription($expectedDescription, $command, ['show-hidden-options' => true]); } /** @dataProvider getDescribeApplicationTestData */ diff --git a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php index cb383032d257e..7d735dece35da 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php @@ -27,9 +27,10 @@ protected static function getFormat() protected function normalizeOutput($output) { - if (null === $output || !is_array($output = json_decode($output, true))) { + if (null === $output || !\is_array($output = json_decode($output, true))) { return $output; } + return array_map($this->normalizeOutputRecursively(...), $output); } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php index f2a7855070333..53ee707be74a0 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; class BarBucCommand extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/BarHiddenCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/BarHiddenCommand.php index 2d42de46e33ab..eb748bc4c2537 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/BarHiddenCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/BarHiddenCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand5.php b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand5.php index 464631a94d82c..f45f3571488ed 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand5.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand5.php @@ -3,6 +3,8 @@ /* * This file is part of the Symfony package. * + * (c) Fabien Potencier + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php index f8a80c54a6858..e1596c86dc6ab 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php index 39df932b9595d..c9349e19690a6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php index 505b2d58e25df..15faa52eec5c3 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -18,12 +27,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int { try { try { - throw new \Exception('First exception

this is html

'); - } catch (\Exception $e) { - throw new \Exception('Second exception comment', 0, $e); + throw new Exception('First exception

this is html

'); + } catch (Exception $e) { + throw new Exception('Second exception comment', 0, $e); } - } catch (\Exception $e) { - throw new \Exception('Third exception comment', 404, $e); + } catch (Exception $e) { + throw new Exception('Third exception comment', 404, $e); } return 0; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php index 3f826a83ac158..ba15b9ec1f1c9 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; class Foo4Command extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php index a1c60827a5153..6bf45d219649f 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; class Foo5Command extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php index b71022ae525a8..fa0a9eebab1e2 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; class Foo6Command extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooCommand.php index d8c39ae496ca0..0355afd1995d3 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooHiddenCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooHiddenCommand.php index b9ef2576b8242..760c77670d113 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooHiddenCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooHiddenCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooLock2Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooLock2Command.php index d7521c4eeb5e3..d5ed28d4e4e6e 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooLock2Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooLock2Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\LockableTrait; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooLock3Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooLock3Command.php index 78492de6950a8..a4ae039ae7447 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooLock3Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooLock3Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\LockableTrait; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooLockCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooLockCommand.php index df33c171cf819..57f294bdabe21 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooLockCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooLockCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\LockableTrait; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php index e9147352cb662..5e40caf2d4795 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseLowercaseCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseLowercaseCommand.php index 7f0e2c2e6671c..b5db84ea87cef 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseLowercaseCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseLowercaseCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; class FooSameCaseLowercaseCommand extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseUppercaseCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseUppercaseCommand.php index 570726897dd06..ad8117332ec09 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseUppercaseCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseUppercaseCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; class FooSameCaseUppercaseCommand extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php index 72b389a674560..1d69908aeb965 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php index 9867a07a59fb7..fcce9bb51a28d 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooWithoutAliasCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooWithoutAliasCommand.php index 268d0b3906da6..e3c3c0b3c7e3b 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooWithoutAliasCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooWithoutAliasCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php index 9405b091707a6..d73b7d48b324b 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php index 8fe7c07712888..5cea01bd5ead7 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure has single blank line at start when using block element +// Ensure has single blank line at start when using block element return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->caution('Lorem ipsum dolor sit amet'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php index e5c700d60eb56..34e03df1ebe5a 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure has single blank line between titles and blocks +// Ensure has single blank line between titles and blocks return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->title('Title'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php index 3111873ddde6c..16016ecf488f4 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure that all lines are aligned to the begin of the first line in a very long line block +// Ensure that all lines are aligned to the begin of the first line in a very long line block return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->block( diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php index 3ed897def42ce..b3515dade649c 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php index 8c458ae764dc3..a4b4114d602c6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php index 9bcc68f69e2c5..98cf1441058ed 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php index a893a48bf248f..8a8d2da781c89 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php index 68402cd408a2d..b7fa882767235 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php index 66e8179638821..23916de089360 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php index 311e6b3928478..1b9166149ba33 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure symfony style helper methods handle trailing backslashes properly when decorating user texts +// Ensure symfony style helper methods handle trailing backslashes properly when decorating user texts return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php index d4afa45cf37c4..89ea41ed8446e 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Helper\TableSeparator; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php index e44b18b76654d..8568b0a7ef4fb 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Helper\TableCell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure formatting tables when using multiple headers with TableCell +// Ensure formatting tables when using multiple headers with TableCell return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->horizontalTable(['a', 'b', 'c', 'd'], [[1, 2, 3], [4, 5], [7, 8, 9]]); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php index a16ad505d2bc4..655e46336a382 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure has single blank line between blocks +// Ensure has single blank line between blocks return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->warning('Warning'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php index 6b47969eeeba6..db438923a9cea 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php index 8460e7ececf37..d6971e5daa201 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure texts with emojis don't make longer lines than expected +// Ensure texts with emojis don't make longer lines than expected return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->success('Lorem ipsum dolor sit amet'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php index 1070394a89726..861d118b0c0fc 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php index e6228fe0ba423..ece15fabd50de 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php index 99253a6c08a83..473fe017c36ec 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure has single blank line between two titles +// Ensure has single blank line between two titles return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->title('First title'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php index b2f3d99546afb..e107b5b895313 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure has single blank line after any text and a title +// Ensure has single blank line after any text and a title return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); @@ -18,17 +27,17 @@ $output->write(''); $output->title('Third title'); - //Ensure edge case by appending empty strings to history: + // Ensure edge case by appending empty strings to history: $output->write('Lorem ipsum dolor sit amet'); $output->write(['', '', '']); $output->title('Fourth title'); - //Ensure have manual control over number of blank lines: + // Ensure have manual control over number of blank lines: $output->writeln('Lorem ipsum dolor sit amet'); - $output->writeln(['', '']); //Should append an extra blank line + $output->writeln(['', '']); // Should append an extra blank line $output->title('Fifth title'); $output->writeln('Lorem ipsum dolor sit amet'); - $output->newLine(2); //Should append an extra blank line + $output->newLine(2); // Should append an extra blank line $output->title('Fifth title'); }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php index 3b215c7f2c5a6..457e28a9c0868 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure has single blank line after any text and a title +// Ensure has single blank line after any text and a title return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); @@ -18,17 +27,17 @@ $output->write(''); $output->title('Third title'); - //Ensure edge case by appending empty strings to history: + // Ensure edge case by appending empty strings to history: $output->write('Lorem ipsum dolor sit amet'); - $output->write(new \ArrayIterator(['', '', ''])); + $output->write(new ArrayIterator(['', '', ''])); $output->title('Fourth title'); - //Ensure have manual control over number of blank lines: + // Ensure have manual control over number of blank lines: $output->writeln('Lorem ipsum dolor sit amet'); - $output->writeln(new \ArrayIterator(['', ''])); //Should append an extra blank line + $output->writeln(new ArrayIterator(['', ''])); // Should append an extra blank line $output->title('Fifth title'); $output->writeln('Lorem ipsum dolor sit amet'); - $output->newLine(2); //Should append an extra blank line + $output->newLine(2); // Should append an extra blank line $output->title('Fifth title'); }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php index 6fba5737fce39..16a472d662855 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure has proper line ending before outputting a text block like with SymfonyStyle::listing() or SymfonyStyle::text() +// Ensure has proper line ending before outputting a text block like with SymfonyStyle::listing() or SymfonyStyle::text() return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); @@ -14,7 +23,7 @@ 'consectetur adipiscing elit', ]); - //Even using write: + // Even using write: $output->write('Lorem ipsum dolor sit amet'); $output->listing([ 'Lorem ipsum dolor sit amet', diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php index 3278f6ea05b12..245ee299c362e 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure has proper blank line after text block when using a block like with SymfonyStyle::success +// Ensure has proper blank line after text block when using a block like with SymfonyStyle::success return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php index 037c6ab6b3fe5..5edcbe46bda07 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure questions do not output anything when input is non-interactive +// Ensure questions do not output anything when input is non-interactive return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->title('Title'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php index fe9d484d252b3..def8dd3f19533 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Helper\TableCell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure formatting tables when using multiple headers with TableCell +// Ensure formatting tables when using multiple headers with TableCell return function (InputInterface $input, OutputInterface $output) { $headers = [ [new TableCell('Main table title', ['colspan' => 3])], diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php index 73af4ae1e2614..dca3fe6143661 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure that all lines are aligned to the begin of the first line in a multi-line block +// Ensure that all lines are aligned to the begin of the first line in a multi-line block return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->block(['Custom block', 'Second custom block line'], 'CUSTOM', 'fg=white;bg=green', 'X ', true); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php index 3c9c744050185..b2c25b7717016 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -//Ensure that questions have the expected outputs +// Ensure that questions have the expected outputs return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $stream = fopen('php://memory', 'r+', false); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php index 6487bc3b1fbb2..55736eee77895 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; @@ -8,7 +17,7 @@ return function (InputInterface $input, OutputInterface $output) { $style = new SymfonyStyle($input, $output); - foreach ($style->progressIterate(\range(1, 10)) as $step) { + foreach ($style->progressIterate(range(1, 10)) as $step) { // noop } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php b/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php index cc3967c064820..116261d40becf 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php b/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php index 3b8dcb2d2eac3..fc4b0389b43a8 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/TestCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/TestCommand.php index 1d2b45af10a96..f5e04946815f6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/TestCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/TestCommand.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php b/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php index 12cf744eaffd9..6b33210c216e5 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Symfony\Component\Console\Command\SignalableCommandInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -8,14 +17,14 @@ $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { - $vendor = \dirname($vendor); + $vendor = dirname($vendor); } require $vendor.'/vendor/autoload.php'; (new class() extends SingleCommandApplication implements SignalableCommandInterface { public function getSubscribedSignals(): array { - return [SIGINT]; + return [\SIGINT]; } public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false @@ -23,7 +32,7 @@ public function handleSignal(int $signal, int|false $previousExitCode = 0): int| exit(0); } }) - ->setCode(function(InputInterface $input, OutputInterface $output) { + ->setCode(function (InputInterface $input, OutputInterface $output) { $this->getHelper('question') ->ask($input, $output, new ChoiceQuestion('😊', ['y'])); diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 4af12e34c0680..959325c616190 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -102,7 +102,7 @@ public static function renderProvider() ['ISBN', 'Title', 'Author'], $books, 'default', -<<<'TABLE' + <<<'TABLE' +---------------+--------------------------+------------------+ | ISBN | Title | Author | +---------------+--------------------------+------------------+ @@ -191,7 +191,7 @@ public static function renderProvider() ['80-902734-1-6', 'And Then There Were None', 'Agatha Christie'], ], 'default', -<<<'TABLE' + <<<'TABLE' +---------------+--------------------------+------------------+ | ISBN | Title | | +---------------+--------------------------+------------------+ @@ -212,7 +212,7 @@ public static function renderProvider() ['80-902734-1-6', 'And Then There Were None', 'Agatha Christie'], ], 'default', -<<<'TABLE' + <<<'TABLE' +---------------+--------------------------+------------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | | 9971-5-0210-0 | | | @@ -231,7 +231,7 @@ public static function renderProvider() ['960-425-059-0', 'The Lord of the Rings', "J. R. R.\nTolkien"], ], 'default', -<<<'TABLE' + <<<'TABLE' +---------------+----------------------------+-----------------+ | ISBN | Title | Author | +---------------+----------------------------+-----------------+ @@ -251,7 +251,7 @@ public static function renderProvider() ['ISBN', 'Title'], [], 'default', -<<<'TABLE' + <<<'TABLE' +------+-------+ | ISBN | Title | +------+-------+ @@ -271,7 +271,7 @@ public static function renderProvider() ['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'], ], 'default', -<<<'TABLE' + <<<'TABLE' +---------------+----------------------+-----------------+ | ISBN | Title | Author | +---------------+----------------------+-----------------+ @@ -288,7 +288,7 @@ public static function renderProvider() ['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'], ], 'default', -<<<'TABLE' + <<<'TABLE' +----------------------------------+----------------------+-----------------+ | ISBN | Title | Author | +----------------------------------+----------------------+-----------------+ @@ -320,7 +320,7 @@ public static function renderProvider() ], ], 'default', -<<<'TABLE' + <<<'TABLE' +-------------------------------+-------------------------------+-----------------------------+ | ISBN | Title | Author | +-------------------------------+-------------------------------+-----------------------------+ @@ -347,7 +347,7 @@ public static function renderProvider() ], ], 'default', -<<<'TABLE' + <<<'TABLE' +-----+-----+-----+ | Foo | Bar | Baz | +-----+-----+-----+ @@ -366,7 +366,7 @@ public static function renderProvider() ], ], 'default', -<<<'TABLE' + <<<'TABLE' +-----+-----+------+ | Foo | Bar | Baz | +-----+-----+------+ @@ -392,7 +392,7 @@ public static function renderProvider() ['80-902734-1-7', 'Test'], ], 'default', -<<<'TABLE' + <<<'TABLE' +---------------+---------------+-----------------+ | ISBN | Title | Author | +---------------+---------------+-----------------+ @@ -425,7 +425,7 @@ public static function renderProvider() ['J. R. R'], ], 'default', -<<<'TABLE' + <<<'TABLE' +------------------+---------+-----------------+ | ISBN | Title | Author | +------------------+---------+-----------------+ @@ -460,7 +460,7 @@ public static function renderProvider() ], ], 'default', -<<<'TABLE' + <<<'TABLE' +-----------------+-------+-----------------+ | ISBN | Title | Author | +-----------------+-------+-----------------+ @@ -497,7 +497,7 @@ public static function renderProvider() ['Charles Dickens'], ], 'default', -<<<'TABLE' + <<<'TABLE' +-----------------+-------+-----------------+ | ISBN | Title | Author | +-----------------+-------+-----------------+ @@ -524,7 +524,7 @@ public static function renderProvider() ['Charles Dickens'], ], 'default', -<<<'TABLE' + <<<'TABLE' +---------------+-----------------+ | ISBN | Author | +---------------+-----------------+ @@ -542,7 +542,7 @@ public static function renderProvider() ], [], 'default', -<<<'TABLE' + <<<'TABLE' +------+-------+--------+ | Main title | +------+-------+--------+ @@ -560,9 +560,9 @@ public static function renderProvider() new TableCell('3', ['colspan' => 2]), new TableCell('4', ['colspan' => 2]), ], - ], + ], 'default', -<<<'TABLE' + <<<'TABLE' +---+--+--+---+--+---+--+---+--+ | 1 | 2 | 3 | 4 | +---+--+--+---+--+---+--+---+--+ @@ -595,7 +595,7 @@ public static function renderProvider() +-----------------+------------------+---------+ TABLE - , + , true, ], 'Row with formatted cells containing a newline' => [ @@ -607,7 +607,7 @@ public static function renderProvider() new TableSeparator(), [ 'foo', - new TableCell('Dont break'."\n".'here', ['rowspan' => 2]), + new TableCell('Dont break'."\n".'here', ['rowspan' => 2]), ], [ 'bar', @@ -624,77 +624,77 @@ public static function renderProvider() +-------+------------+ TABLE - , + , true, ], 'TabeCellStyle with align. Also with rowspan and colspan > 1' => [ - [ - new TableCell( - 'ISBN', - [ - 'style' => new TableCellStyle([ - 'align' => 'right', - ]), - ] - ), - 'Title', - new TableCell( - 'Author', - [ - 'style' => new TableCellStyle([ - 'align' => 'center', - ]), - ] - ), - ], - [ - [ - new TableCell( - '978', - [ - 'style' => new TableCellStyle([ - 'align' => 'center', - ]), - ] - ), - 'De Monarchia', - new TableCell( - "Dante Alighieri \nspans multiple rows rows Dante Alighieri \nspans multiple rows rows", - [ - 'rowspan' => 2, - 'style' => new TableCellStyle([ - 'align' => 'center', - ]), - ] - ), - ], - [ - '99921-58-10-7', - 'Divine Comedy', - ], - new TableSeparator(), - [ - new TableCell( - 'test', - [ - 'colspan' => 2, - 'style' => new TableCellStyle([ - 'align' => 'center', - ]), - ] - ), - new TableCell( - 'tttt', - [ - 'style' => new TableCellStyle([ - 'align' => 'right', - ]), - ] - ), - ], - ], - 'default', -<<<'TABLE' + [ + new TableCell( + 'ISBN', + [ + 'style' => new TableCellStyle([ + 'align' => 'right', + ]), + ] + ), + 'Title', + new TableCell( + 'Author', + [ + 'style' => new TableCellStyle([ + 'align' => 'center', + ]), + ] + ), + ], + [ + [ + new TableCell( + '978', + [ + 'style' => new TableCellStyle([ + 'align' => 'center', + ]), + ] + ), + 'De Monarchia', + new TableCell( + "Dante Alighieri \nspans multiple rows rows Dante Alighieri \nspans multiple rows rows", + [ + 'rowspan' => 2, + 'style' => new TableCellStyle([ + 'align' => 'center', + ]), + ] + ), + ], + [ + '99921-58-10-7', + 'Divine Comedy', + ], + new TableSeparator(), + [ + new TableCell( + 'test', + [ + 'colspan' => 2, + 'style' => new TableCellStyle([ + 'align' => 'center', + ]), + ] + ), + new TableCell( + 'tttt', + [ + 'style' => new TableCellStyle([ + 'align' => 'right', + ]), + ] + ), + ], + ], + 'default', + <<<'TABLE' +---------------+---------------+-------------------------------------------+ | ISBN | Title | Author | +---------------+---------------+-------------------------------------------+ @@ -706,66 +706,66 @@ public static function renderProvider() +---------------+---------------+-------------------------------------------+ TABLE - , - ], + , + ], 'TabeCellStyle with fg,bg. Also with rowspan and colspan > 1' => [ [], [ - [ - new TableCell( - '978', - [ - 'style' => new TableCellStyle([ - 'fg' => 'black', - 'bg' => 'green', - ]), - ] - ), - 'De Monarchia', - new TableCell( - "Dante Alighieri \nspans multiple rows rows Dante Alighieri \nspans multiple rows rows", - [ - 'rowspan' => 2, - 'style' => new TableCellStyle([ - 'fg' => 'red', - 'bg' => 'green', - 'align' => 'center', - ]), - ] - ), - ], - - [ - '99921-58-10-7', - 'Divine Comedy', - ], - new TableSeparator(), - [ - new TableCell( - 'test', - [ - 'colspan' => 2, - 'style' => new TableCellStyle([ - 'fg' => 'red', - 'bg' => 'green', - 'align' => 'center', - ]), - ] - ), - new TableCell( - 'tttt', - [ - 'style' => new TableCellStyle([ - 'fg' => 'red', - 'bg' => 'green', - 'align' => 'right', - ]), - ] - ), - ], + [ + new TableCell( + '978', + [ + 'style' => new TableCellStyle([ + 'fg' => 'black', + 'bg' => 'green', + ]), + ] + ), + 'De Monarchia', + new TableCell( + "Dante Alighieri \nspans multiple rows rows Dante Alighieri \nspans multiple rows rows", + [ + 'rowspan' => 2, + 'style' => new TableCellStyle([ + 'fg' => 'red', + 'bg' => 'green', + 'align' => 'center', + ]), + ] + ), + ], + + [ + '99921-58-10-7', + 'Divine Comedy', + ], + new TableSeparator(), + [ + new TableCell( + 'test', + [ + 'colspan' => 2, + 'style' => new TableCellStyle([ + 'fg' => 'red', + 'bg' => 'green', + 'align' => 'center', + ]), + ] + ), + new TableCell( + 'tttt', + [ + 'style' => new TableCellStyle([ + 'fg' => 'red', + 'bg' => 'green', + 'align' => 'right', + ]), + ] + ), + ], ], 'default', -<<<'TABLE' + <<<'TABLE' +---------------+---------------+-------------------------------------------+ | 978 | De Monarchia | Dante Alighieri | | 99921-58-10-7 | Divine Comedy | spans multiple rows rows Dante Alighieri | @@ -775,9 +775,9 @@ public static function renderProvider() +---------------+---------------+-------------------------------------------+ TABLE - , - true, - ], + , + true, + ], 'TabeCellStyle with cellFormat. Also with rowspan and colspan > 1' => [ [ new TableCell( @@ -820,7 +820,7 @@ public static function renderProvider() ], ], 'default', -<<<'TABLE' + <<<'TABLE' +----------------+---------------+---------------------+ | ISBN | Title | Author | +----------------+---------------+---------------------+ @@ -832,7 +832,7 @@ public static function renderProvider() TABLE , true, - ], + ], ]; } @@ -1288,7 +1288,7 @@ public static function renderSetTitle() TABLE , true, - ], + ], 'header contains multiple lines' => [ 'Multiline'."\n".'header'."\n".'here', 'footer', @@ -1558,18 +1558,18 @@ public function testWithColspanAndMaxWith() $table->setColumnMaxWidth(1, 15); $table->setColumnMaxWidth(2, 15); $table->setRows([ - [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], - new TableSeparator(), - [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], - new TableSeparator(), - [new TableCell('Lorem ipsum dolor sit amet, consectetur ', ['colspan' => 2]), 'hello world'], - new TableSeparator(), - ['hello world', new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit', ['colspan' => 2])], - new TableSeparator(), - ['hello ', new TableCell('world', ['colspan' => 1]), 'Lorem ipsum dolor sit amet, consectetur'], - new TableSeparator(), - ['Symfony ', new TableCell('Test', ['colspan' => 1]), 'Lorem ipsum dolor sit amet, consectetur'], - ]) + [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], + new TableSeparator(), + [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], + new TableSeparator(), + [new TableCell('Lorem ipsum dolor sit amet, consectetur ', ['colspan' => 2]), 'hello world'], + new TableSeparator(), + ['hello world', new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit', ['colspan' => 2])], + new TableSeparator(), + ['hello ', new TableCell('world', ['colspan' => 1]), 'Lorem ipsum dolor sit amet, consectetur'], + new TableSeparator(), + ['Symfony ', new TableCell('Test', ['colspan' => 1]), 'Lorem ipsum dolor sit amet, consectetur'], + ]) ; $table->render(); @@ -1845,17 +1845,17 @@ public static function provideRenderVerticalTests(): \Traversable yield 'Borderless style' => [ << [ << [ <<assertEquals('[options] [--] []', $definition->getSynopsis(true), '->getSynopsis(true) groups options in [options]'); } From 4d86a422f18c346f80cc70c3d26384a6a39bd709 Mon Sep 17 00:00:00 2001 From: flkasper Date: Sun, 31 Mar 2024 21:33:57 +0200 Subject: [PATCH 03/15] Change style of deprecated option to inline formatting --- .../Component/Console/Descriptor/TextDescriptor.php | 2 +- .../Component/Console/Formatter/OutputFormatter.php | 1 - .../Console/Tests/Formatter/OutputFormatterTest.php | 7 ------- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index fad5353664023..eb90f1bd759e8 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -102,7 +102,7 @@ protected function describeInputDefinition(InputDefinition $definition, array $o } if ($inputOptions) { - if ($showArguments) { + if ($inputArguments) { $this->writeText("\n"); } $laterOptions = []; diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 97c2663120587..3c8c287e8375f 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -74,7 +74,6 @@ public function __construct( $this->setStyle('info', new OutputFormatterStyle('green')); $this->setStyle('comment', new OutputFormatterStyle('yellow')); $this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); - $this->setStyle('text_error', new OutputFormatterStyle('red')); foreach ($styles as $name => $style) { $this->setStyle($name, $style); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index 655624f60dd9d..f62fa088907d3 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -51,7 +51,6 @@ public function testBundledStyles() $this->assertTrue($formatter->hasStyle('info')); $this->assertTrue($formatter->hasStyle('comment')); $this->assertTrue($formatter->hasStyle('question')); - $this->assertTrue($formatter->hasStyle('text_error')); $this->assertEquals( "\033[37;41msome error\033[39;49m", @@ -69,10 +68,6 @@ public function testBundledStyles() "\033[30;46msome question\033[39;49m", $formatter->format('some question') ); - $this->assertEquals( - "\033[31msome text_error\033[39m", - $formatter->format('some text_error') - ); } public function testNestedStyles() @@ -241,7 +236,6 @@ public function testFormatterHasStyles() $formatter = new OutputFormatter(false); $this->assertTrue($formatter->hasStyle('error')); - $this->assertTrue($formatter->hasStyle('text_error')); $this->assertTrue($formatter->hasStyle('info')); $this->assertTrue($formatter->hasStyle('comment')); $this->assertTrue($formatter->hasStyle('question')); @@ -298,7 +292,6 @@ public static function provideDecoratedAndNonDecoratedOutput() { return [ ['some error', 'some error', "\033[37;41msome error\033[39;49m"], - ['some error', 'some error', "\033[31msome error\033[39m"], ['some info', 'some info', "\033[32msome info\033[39m"], ['some comment', 'some comment', "\033[33msome comment\033[39m"], ['some question', 'some question', "\033[30;46msome question\033[39;49m"], From 69b4bf8c5a6e1a28288d5bbfaffa5a35e96d9a99 Mon Sep 17 00:00:00 2001 From: flkasper Date: Sat, 6 Apr 2024 16:50:29 +0200 Subject: [PATCH 04/15] [Console] Change color of deprecated option to gray --- src/Symfony/Component/Console/Command/Command.php | 6 ++++-- src/Symfony/Component/Console/Descriptor/TextDescriptor.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 4a29d5d85c655..a15c19d3cdfb1 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -19,6 +19,7 @@ use Symfony\Component\Console\Exception\ExceptionInterface; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\LogicException; +use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Helper\HelperInterface; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Input\InputArgument; @@ -275,7 +276,7 @@ public function run(InputInterface $input, OutputInterface $output): int $input->validate(); if (isset($inputDefinition)) { - $this->printDeprecationMessages($inputDefinition, $input, $output); + $this->writeDeprecationMessages($inputDefinition, $input, $output); } if ($this->code) { @@ -653,7 +654,7 @@ public function getHelper(string $name): HelperInterface return $this->helperSet->get($name); } - private function printDeprecationMessages(InputDefinition $inputDefinition, InputInterface $input, OutputInterface $output): void + private function writeDeprecationMessages(InputDefinition $inputDefinition, InputInterface $input, OutputInterface $output): void { $deprecationMessages = []; foreach ($inputDefinition->getOptions() as $inputOption) { @@ -670,6 +671,7 @@ private function printDeprecationMessages(InputDefinition $inputDefinition, Inpu } } if (!empty($deprecationMessages)) { + /** @var FormatterHelper $formatter */ $formatter = $this->getHelper('formatter'); $output->writeln($formatter->formatBlock($deprecationMessages, 'fg=black;bg=yellow', true)); } diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index eb90f1bd759e8..055c2aa44e601 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -74,7 +74,7 @@ protected function describeInputOption(InputOption $option, array $options = []) $spacingWidth = $totalWidth - Helper::width($synopsis); $this->writeText(\sprintf(' %s %s%s%s%s', - \sprintf('<%1$s>%2$s', $option->isDeprecated() ? 'text_error' : 'info', $synopsis), + \sprintf('<%1$s>%2$s', $option->isDeprecated() ? 'fg=gray;' : 'info', $synopsis), str_repeat(' ', $spacingWidth), // + 4 = 2 spaces before , 2 spaces after preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()), From e2d3f12f8cb9f9c04c09b59a392601e80ffa452f Mon Sep 17 00:00:00 2001 From: flkasper Date: Sat, 6 Apr 2024 17:02:01 +0200 Subject: [PATCH 05/15] [Console] Fixed test after color change --- src/Symfony/Component/Console/Tests/Fixtures/command_5.txt | 2 +- .../Console/Tests/Fixtures/command_5_with_hidden_options.txt | 2 +- .../Console/Tests/Fixtures/input_option_deprecated.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt index b1f51aa617ac9..c0c164ce31b22 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt @@ -5,7 +5,7 @@ descriptor:command5 [options] Options: - -y, --deprecated_option + -y, --deprecated_option Help: command 5 help diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt index f24946e0d375d..724d2ee943988 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt @@ -5,7 +5,7 @@ descriptor:command5 [options] Options: - -y, --deprecated_option + -y, --deprecated_option -z, --hidden_option Help: diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt index bfc1a40f6f432..32703f812337a 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt @@ -1 +1 @@ --o, --option_name deprecated option description +-o, --option_name deprecated option description From ece8b7aa73be9189746e62173525c6db3e481337 Mon Sep 17 00:00:00 2001 From: flkasper Date: Mon, 8 Apr 2024 09:59:16 +0200 Subject: [PATCH 06/15] [Console] Revert unrelated (style) changes --- .../Console/Helper/ProgressIndicator.php | 1 + .../Style/SymfonyStyle/command/command_4.php | 19 +- .../Console/Tests/Helper/TableTest.php | 322 +++++++++--------- 3 files changed, 167 insertions(+), 175 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/ProgressIndicator.php b/src/Symfony/Component/Console/Helper/ProgressIndicator.php index d06897d8543a2..30baff8f24392 100644 --- a/src/Symfony/Component/Console/Helper/ProgressIndicator.php +++ b/src/Symfony/Component/Console/Helper/ProgressIndicator.php @@ -54,6 +54,7 @@ public function __construct( private int $indicatorChangeInterval = 100, ?array $indicatorValues = null, ) { + $format ??= $this->determineBestFormat(); $indicatorValues ??= ['-', '\\', '|', '/']; $indicatorValues = array_values($indicatorValues); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php index e107b5b895313..b2f3d99546afb 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure has single blank line after any text and a title +//Ensure has single blank line after any text and a title return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); @@ -27,17 +18,17 @@ $output->write(''); $output->title('Third title'); - // Ensure edge case by appending empty strings to history: + //Ensure edge case by appending empty strings to history: $output->write('Lorem ipsum dolor sit amet'); $output->write(['', '', '']); $output->title('Fourth title'); - // Ensure have manual control over number of blank lines: + //Ensure have manual control over number of blank lines: $output->writeln('Lorem ipsum dolor sit amet'); - $output->writeln(['', '']); // Should append an extra blank line + $output->writeln(['', '']); //Should append an extra blank line $output->title('Fifth title'); $output->writeln('Lorem ipsum dolor sit amet'); - $output->newLine(2); // Should append an extra blank line + $output->newLine(2); //Should append an extra blank line $output->title('Fifth title'); }; diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 959325c616190..4a560713e1d5d 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -102,7 +102,7 @@ public static function renderProvider() ['ISBN', 'Title', 'Author'], $books, 'default', - <<<'TABLE' +<<<'TABLE' +---------------+--------------------------+------------------+ | ISBN | Title | Author | +---------------+--------------------------+------------------+ @@ -191,7 +191,7 @@ public static function renderProvider() ['80-902734-1-6', 'And Then There Were None', 'Agatha Christie'], ], 'default', - <<<'TABLE' +<<<'TABLE' +---------------+--------------------------+------------------+ | ISBN | Title | | +---------------+--------------------------+------------------+ @@ -212,7 +212,7 @@ public static function renderProvider() ['80-902734-1-6', 'And Then There Were None', 'Agatha Christie'], ], 'default', - <<<'TABLE' +<<<'TABLE' +---------------+--------------------------+------------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | | 9971-5-0210-0 | | | @@ -231,7 +231,7 @@ public static function renderProvider() ['960-425-059-0', 'The Lord of the Rings', "J. R. R.\nTolkien"], ], 'default', - <<<'TABLE' +<<<'TABLE' +---------------+----------------------------+-----------------+ | ISBN | Title | Author | +---------------+----------------------------+-----------------+ @@ -251,7 +251,7 @@ public static function renderProvider() ['ISBN', 'Title'], [], 'default', - <<<'TABLE' +<<<'TABLE' +------+-------+ | ISBN | Title | +------+-------+ @@ -271,7 +271,7 @@ public static function renderProvider() ['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'], ], 'default', - <<<'TABLE' +<<<'TABLE' +---------------+----------------------+-----------------+ | ISBN | Title | Author | +---------------+----------------------+-----------------+ @@ -288,7 +288,7 @@ public static function renderProvider() ['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'], ], 'default', - <<<'TABLE' +<<<'TABLE' +----------------------------------+----------------------+-----------------+ | ISBN | Title | Author | +----------------------------------+----------------------+-----------------+ @@ -320,7 +320,7 @@ public static function renderProvider() ], ], 'default', - <<<'TABLE' +<<<'TABLE' +-------------------------------+-------------------------------+-----------------------------+ | ISBN | Title | Author | +-------------------------------+-------------------------------+-----------------------------+ @@ -347,7 +347,7 @@ public static function renderProvider() ], ], 'default', - <<<'TABLE' +<<<'TABLE' +-----+-----+-----+ | Foo | Bar | Baz | +-----+-----+-----+ @@ -366,7 +366,7 @@ public static function renderProvider() ], ], 'default', - <<<'TABLE' +<<<'TABLE' +-----+-----+------+ | Foo | Bar | Baz | +-----+-----+------+ @@ -392,7 +392,7 @@ public static function renderProvider() ['80-902734-1-7', 'Test'], ], 'default', - <<<'TABLE' +<<<'TABLE' +---------------+---------------+-----------------+ | ISBN | Title | Author | +---------------+---------------+-----------------+ @@ -425,7 +425,7 @@ public static function renderProvider() ['J. R. R'], ], 'default', - <<<'TABLE' +<<<'TABLE' +------------------+---------+-----------------+ | ISBN | Title | Author | +------------------+---------+-----------------+ @@ -460,7 +460,7 @@ public static function renderProvider() ], ], 'default', - <<<'TABLE' +<<<'TABLE' +-----------------+-------+-----------------+ | ISBN | Title | Author | +-----------------+-------+-----------------+ @@ -497,7 +497,7 @@ public static function renderProvider() ['Charles Dickens'], ], 'default', - <<<'TABLE' +<<<'TABLE' +-----------------+-------+-----------------+ | ISBN | Title | Author | +-----------------+-------+-----------------+ @@ -524,7 +524,7 @@ public static function renderProvider() ['Charles Dickens'], ], 'default', - <<<'TABLE' +<<<'TABLE' +---------------+-----------------+ | ISBN | Author | +---------------+-----------------+ @@ -542,7 +542,7 @@ public static function renderProvider() ], [], 'default', - <<<'TABLE' +<<<'TABLE' +------+-------+--------+ | Main title | +------+-------+--------+ @@ -560,9 +560,9 @@ public static function renderProvider() new TableCell('3', ['colspan' => 2]), new TableCell('4', ['colspan' => 2]), ], - ], + ], 'default', - <<<'TABLE' +<<<'TABLE' +---+--+--+---+--+---+--+---+--+ | 1 | 2 | 3 | 4 | +---+--+--+---+--+---+--+---+--+ @@ -595,7 +595,7 @@ public static function renderProvider() +-----------------+------------------+---------+ TABLE - , + , true, ], 'Row with formatted cells containing a newline' => [ @@ -607,7 +607,7 @@ public static function renderProvider() new TableSeparator(), [ 'foo', - new TableCell('Dont break'."\n".'here', ['rowspan' => 2]), + new TableCell('Dont break'."\n".'here', ['rowspan' => 2]), ], [ 'bar', @@ -624,77 +624,77 @@ public static function renderProvider() +-------+------------+ TABLE - , + , true, ], 'TabeCellStyle with align. Also with rowspan and colspan > 1' => [ - [ - new TableCell( - 'ISBN', - [ - 'style' => new TableCellStyle([ - 'align' => 'right', - ]), - ] - ), - 'Title', - new TableCell( - 'Author', - [ - 'style' => new TableCellStyle([ - 'align' => 'center', - ]), - ] - ), - ], - [ - [ - new TableCell( - '978', - [ - 'style' => new TableCellStyle([ - 'align' => 'center', - ]), - ] - ), - 'De Monarchia', - new TableCell( - "Dante Alighieri \nspans multiple rows rows Dante Alighieri \nspans multiple rows rows", - [ - 'rowspan' => 2, - 'style' => new TableCellStyle([ - 'align' => 'center', - ]), - ] - ), - ], - [ - '99921-58-10-7', - 'Divine Comedy', - ], - new TableSeparator(), - [ - new TableCell( - 'test', - [ - 'colspan' => 2, - 'style' => new TableCellStyle([ - 'align' => 'center', - ]), - ] - ), - new TableCell( - 'tttt', - [ - 'style' => new TableCellStyle([ - 'align' => 'right', - ]), - ] - ), - ], - ], - 'default', - <<<'TABLE' + [ + new TableCell( + 'ISBN', + [ + 'style' => new TableCellStyle([ + 'align' => 'right', + ]), + ] + ), + 'Title', + new TableCell( + 'Author', + [ + 'style' => new TableCellStyle([ + 'align' => 'center', + ]), + ] + ), + ], + [ + [ + new TableCell( + '978', + [ + 'style' => new TableCellStyle([ + 'align' => 'center', + ]), + ] + ), + 'De Monarchia', + new TableCell( + "Dante Alighieri \nspans multiple rows rows Dante Alighieri \nspans multiple rows rows", + [ + 'rowspan' => 2, + 'style' => new TableCellStyle([ + 'align' => 'center', + ]), + ] + ), + ], + [ + '99921-58-10-7', + 'Divine Comedy', + ], + new TableSeparator(), + [ + new TableCell( + 'test', + [ + 'colspan' => 2, + 'style' => new TableCellStyle([ + 'align' => 'center', + ]), + ] + ), + new TableCell( + 'tttt', + [ + 'style' => new TableCellStyle([ + 'align' => 'right', + ]), + ] + ), + ], + ], + 'default', +<<<'TABLE' +---------------+---------------+-------------------------------------------+ | ISBN | Title | Author | +---------------+---------------+-------------------------------------------+ @@ -706,66 +706,66 @@ public static function renderProvider() +---------------+---------------+-------------------------------------------+ TABLE - , - ], + , + ], 'TabeCellStyle with fg,bg. Also with rowspan and colspan > 1' => [ [], [ - [ - new TableCell( - '978', - [ - 'style' => new TableCellStyle([ - 'fg' => 'black', - 'bg' => 'green', - ]), - ] - ), - 'De Monarchia', - new TableCell( - "Dante Alighieri \nspans multiple rows rows Dante Alighieri \nspans multiple rows rows", - [ - 'rowspan' => 2, - 'style' => new TableCellStyle([ - 'fg' => 'red', - 'bg' => 'green', - 'align' => 'center', - ]), - ] - ), - ], - - [ - '99921-58-10-7', - 'Divine Comedy', - ], - new TableSeparator(), - [ - new TableCell( - 'test', - [ - 'colspan' => 2, - 'style' => new TableCellStyle([ - 'fg' => 'red', - 'bg' => 'green', - 'align' => 'center', - ]), - ] - ), - new TableCell( - 'tttt', - [ - 'style' => new TableCellStyle([ - 'fg' => 'red', - 'bg' => 'green', - 'align' => 'right', - ]), - ] - ), - ], + [ + new TableCell( + '978', + [ + 'style' => new TableCellStyle([ + 'fg' => 'black', + 'bg' => 'green', + ]), + ] + ), + 'De Monarchia', + new TableCell( + "Dante Alighieri \nspans multiple rows rows Dante Alighieri \nspans multiple rows rows", + [ + 'rowspan' => 2, + 'style' => new TableCellStyle([ + 'fg' => 'red', + 'bg' => 'green', + 'align' => 'center', + ]), + ] + ), + ], + + [ + '99921-58-10-7', + 'Divine Comedy', + ], + new TableSeparator(), + [ + new TableCell( + 'test', + [ + 'colspan' => 2, + 'style' => new TableCellStyle([ + 'fg' => 'red', + 'bg' => 'green', + 'align' => 'center', + ]), + ] + ), + new TableCell( + 'tttt', + [ + 'style' => new TableCellStyle([ + 'fg' => 'red', + 'bg' => 'green', + 'align' => 'right', + ]), + ] + ), + ], ], 'default', - <<<'TABLE' +<<<'TABLE' +---------------+---------------+-------------------------------------------+ | 978 | De Monarchia | Dante Alighieri | | 99921-58-10-7 | Divine Comedy | spans multiple rows rows Dante Alighieri | @@ -775,9 +775,9 @@ public static function renderProvider() +---------------+---------------+-------------------------------------------+ TABLE - , - true, - ], + , + true, + ], 'TabeCellStyle with cellFormat. Also with rowspan and colspan > 1' => [ [ new TableCell( @@ -820,7 +820,7 @@ public static function renderProvider() ], ], 'default', - <<<'TABLE' +<<<'TABLE' +----------------+---------------+---------------------+ | ISBN | Title | Author | +----------------+---------------+---------------------+ @@ -832,7 +832,7 @@ public static function renderProvider() TABLE , true, - ], + ], ]; } @@ -1288,7 +1288,7 @@ public static function renderSetTitle() TABLE , true, - ], + ], 'header contains multiple lines' => [ 'Multiline'."\n".'header'."\n".'here', 'footer', @@ -1558,18 +1558,18 @@ public function testWithColspanAndMaxWith() $table->setColumnMaxWidth(1, 15); $table->setColumnMaxWidth(2, 15); $table->setRows([ - [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], - new TableSeparator(), - [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], - new TableSeparator(), - [new TableCell('Lorem ipsum dolor sit amet, consectetur ', ['colspan' => 2]), 'hello world'], - new TableSeparator(), - ['hello world', new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit', ['colspan' => 2])], - new TableSeparator(), - ['hello ', new TableCell('world', ['colspan' => 1]), 'Lorem ipsum dolor sit amet, consectetur'], - new TableSeparator(), - ['Symfony ', new TableCell('Test', ['colspan' => 1]), 'Lorem ipsum dolor sit amet, consectetur'], - ]) + [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], + new TableSeparator(), + [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], + new TableSeparator(), + [new TableCell('Lorem ipsum dolor sit amet, consectetur ', ['colspan' => 2]), 'hello world'], + new TableSeparator(), + ['hello world', new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit', ['colspan' => 2])], + new TableSeparator(), + ['hello ', new TableCell('world', ['colspan' => 1]), 'Lorem ipsum dolor sit amet, consectetur'], + new TableSeparator(), + ['Symfony ', new TableCell('Test', ['colspan' => 1]), 'Lorem ipsum dolor sit amet, consectetur'], + ]) ; $table->render(); From a08e4d5c46584d83f4caf5e0e29492c1c33d1ade Mon Sep 17 00:00:00 2001 From: flkasper Date: Mon, 8 Apr 2024 10:31:58 +0200 Subject: [PATCH 07/15] [Console] Apply suggestion changes - Included option shortcut in deprecation message - Applied phpdoc suggestion - Applied remove of console .editorconfig --- src/Symfony/Component/Console/.editorconfig | 7 ------- src/Symfony/Component/Console/Command/Command.php | 7 ++++++- src/Symfony/Component/Console/Input/InputOption.php | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 src/Symfony/Component/Console/.editorconfig diff --git a/src/Symfony/Component/Console/.editorconfig b/src/Symfony/Component/Console/.editorconfig deleted file mode 100644 index 1adf2294b8874..0000000000000 --- a/src/Symfony/Component/Console/.editorconfig +++ /dev/null @@ -1,7 +0,0 @@ -; Unix-style newlines -[Tests/Fixtures/*.{json,md,rst,txt}] -trim_trailing_whitespace = false - -[Tests/Fixtures/*.xml] -trim_trailing_whitespace = false -indent_size = 2 diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index a15c19d3cdfb1..6f99d7bff86d7 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -663,7 +663,12 @@ private function writeDeprecationMessages(InputDefinition $inputDefinition, Inpu $optionName = $inputOption->getName(); $optionValue = $input->getOption($optionName); if (isset($optionValue) && $optionValue !== $inputOption->getDefault()) { - $deprecationMessages[] = sprintf('The option "--%s" is deprecated.', $optionName); + $optionShortcut = $inputOption->getShortcut(); + $deprecationMessages[] = sprintf( + 'The option "--%s%s" is deprecated.', + $optionName, + $optionShortcut === null ? '' : ('|-' . $optionShortcut) + ); } } catch (\InvalidArgumentException $exception) { // option not used, ignore diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 24c56536a941a..c8b3289e51dba 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -51,8 +51,7 @@ class InputOption public const VALUE_NEGATABLE = 16; /** - * The option allows to deprecate command option. - * Option will be marked as deprecated in help output and a warning is printed when the command is executed. + * Mark the option as deprecated in help output. A message is printed when the command is executed. */ public const DEPRECATED = 32; From 02f0e0eb14a907e032474b28dbd55105887d791f Mon Sep 17 00:00:00 2001 From: flkasper Date: Tue, 9 Apr 2024 21:27:12 +0200 Subject: [PATCH 08/15] [Console] Fixed name of method --- .../Component/Console/Input/InputOption.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index c8b3289e51dba..c84252ee8eb47 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -167,7 +167,7 @@ public function acceptValue(): bool */ public function isValueRequired(): bool { - return $this->hastMode(self::VALUE_REQUIRED); + return $this->hasMode(self::VALUE_REQUIRED); } /** @@ -177,7 +177,7 @@ public function isValueRequired(): bool */ public function isValueOptional(): bool { - return $this->hastMode(self::VALUE_OPTIONAL); + return $this->hasMode(self::VALUE_OPTIONAL); } /** @@ -187,7 +187,7 @@ public function isValueOptional(): bool */ public function isArray(): bool { - return $this->hastMode(self::VALUE_IS_ARRAY); + return $this->hasMode(self::VALUE_IS_ARRAY); } /** @@ -197,7 +197,7 @@ public function isArray(): bool */ public function isDeprecated(): bool { - return $this->hastMode(self::DEPRECATED); + return $this->hasMode(self::DEPRECATED); } /** @@ -207,7 +207,7 @@ public function isDeprecated(): bool */ public function isHidden(): bool { - return $this->hastMode(self::HIDDEN); + return $this->hasMode(self::HIDDEN); } /** @@ -217,7 +217,7 @@ public function isHidden(): bool */ public function isNegatable(): bool { - return $this->hastMode(self::VALUE_NEGATABLE); + return $this->hasMode(self::VALUE_NEGATABLE); } /** @@ -300,7 +300,7 @@ public function equals(self $option): bool * * @return bool true if mode is $mode, false otherwise */ - protected function hastMode(int $mode): bool + protected function hasMode(int $mode): bool { return $mode === ($mode & $this->mode); } From d4be218e7d11966f62eaf351af530e19d2f8a2f3 Mon Sep 17 00:00:00 2001 From: flkasper Date: Fri, 12 Apr 2024 00:30:37 +0200 Subject: [PATCH 09/15] [Console] Revert unrelated (style) changes --- .../Console/Helper/QuestionHelper.php | 2 +- .../Console/Tests/Fixtures/BarBucCommand.php | 9 --- .../Tests/Fixtures/BarHiddenCommand.php | 9 --- .../Console/Tests/Fixtures/Foo1Command.php | 9 --- .../Console/Tests/Fixtures/Foo2Command.php | 9 --- .../Console/Tests/Fixtures/Foo3Command.php | 19 ++---- .../Console/Tests/Fixtures/Foo4Command.php | 9 --- .../Console/Tests/Fixtures/Foo5Command.php | 9 --- .../Console/Tests/Fixtures/Foo6Command.php | 9 --- .../Console/Tests/Fixtures/FooCommand.php | 9 --- .../Tests/Fixtures/FooHiddenCommand.php | 9 --- .../Tests/Fixtures/FooLock2Command.php | 9 --- .../Tests/Fixtures/FooLock3Command.php | 9 --- .../Console/Tests/Fixtures/FooLockCommand.php | 9 --- .../Console/Tests/Fixtures/FooOptCommand.php | 9 --- .../Fixtures/FooSameCaseLowercaseCommand.php | 9 --- .../Fixtures/FooSameCaseUppercaseCommand.php | 9 --- .../Fixtures/FooSubnamespaced1Command.php | 9 --- .../Fixtures/FooSubnamespaced2Command.php | 9 --- .../Tests/Fixtures/FooWithoutAliasCommand.php | 9 --- .../Console/Tests/Fixtures/FoobarCommand.php | 9 --- .../Style/SymfonyStyle/command/command_0.php | 11 +--- .../Style/SymfonyStyle/command/command_1.php | 11 +--- .../Style/SymfonyStyle/command/command_10.php | 11 +--- .../Style/SymfonyStyle/command/command_11.php | 9 --- .../Style/SymfonyStyle/command/command_12.php | 9 --- .../Style/SymfonyStyle/command/command_13.php | 9 --- .../Style/SymfonyStyle/command/command_14.php | 9 --- .../Style/SymfonyStyle/command/command_15.php | 9 --- .../Style/SymfonyStyle/command/command_16.php | 9 --- .../Style/SymfonyStyle/command/command_17.php | 11 +--- .../Style/SymfonyStyle/command/command_18.php | 9 --- .../Style/SymfonyStyle/command/command_19.php | 11 +--- .../Style/SymfonyStyle/command/command_2.php | 11 +--- .../Style/SymfonyStyle/command/command_20.php | 9 --- .../Style/SymfonyStyle/command/command_21.php | 11 +--- .../Style/SymfonyStyle/command/command_22.php | 9 --- .../Style/SymfonyStyle/command/command_23.php | 9 --- .../Style/SymfonyStyle/command/command_3.php | 11 +--- .../command/command_4_with_iterators.php | 21 ++----- .../Style/SymfonyStyle/command/command_5.php | 13 +--- .../Style/SymfonyStyle/command/command_6.php | 11 +--- .../Style/SymfonyStyle/command/command_7.php | 11 +--- .../Style/SymfonyStyle/command/command_8.php | 11 +--- .../Style/SymfonyStyle/command/command_9.php | 11 +--- .../command/interactive_command_1.php | 11 +--- .../progress/command_progress_iterate.php | 11 +--- .../TestAmbiguousCommandRegistering.php | 9 --- .../TestAmbiguousCommandRegistering2.php | 9 --- .../Console/Tests/Fixtures/TestCommand.php | 9 --- .../Tests/Fixtures/application_signalable.php | 15 +---- .../Console/Tests/Helper/TableTest.php | 60 +++++++++---------- .../Tests/Input/InputDefinitionTest.php | 10 +--- 53 files changed, 63 insertions(+), 519 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 8e1591ec1b14a..69afc2a67946f 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -55,7 +55,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu } $inputStream = $input instanceof StreamableInputInterface ? $input->getStream() : null; - $inputStream ??= \STDIN; + $inputStream ??= STDIN; try { if (!$question->getValidator()) { diff --git a/src/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php index 53ee707be74a0..f2a7855070333 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; class BarBucCommand extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/BarHiddenCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/BarHiddenCommand.php index eb748bc4c2537..2d42de46e33ab 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/BarHiddenCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/BarHiddenCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php index e1596c86dc6ab..f8a80c54a6858 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php index c9349e19690a6..39df932b9595d 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php index 15faa52eec5c3..505b2d58e25df 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -27,12 +18,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int { try { try { - throw new Exception('First exception

this is html

'); - } catch (Exception $e) { - throw new Exception('Second exception comment', 0, $e); + throw new \Exception('First exception

this is html

'); + } catch (\Exception $e) { + throw new \Exception('Second exception comment', 0, $e); } - } catch (Exception $e) { - throw new Exception('Third exception comment', 404, $e); + } catch (\Exception $e) { + throw new \Exception('Third exception comment', 404, $e); } return 0; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php index ba15b9ec1f1c9..3f826a83ac158 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; class Foo4Command extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php index 6bf45d219649f..a1c60827a5153 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; class Foo5Command extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php index fa0a9eebab1e2..b71022ae525a8 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; class Foo6Command extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooCommand.php index 0355afd1995d3..d8c39ae496ca0 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooHiddenCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooHiddenCommand.php index 760c77670d113..b9ef2576b8242 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooHiddenCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooHiddenCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooLock2Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooLock2Command.php index d5ed28d4e4e6e..d7521c4eeb5e3 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooLock2Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooLock2Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\LockableTrait; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooLock3Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooLock3Command.php index a4ae039ae7447..78492de6950a8 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooLock3Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooLock3Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\LockableTrait; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooLockCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooLockCommand.php index 57f294bdabe21..df33c171cf819 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooLockCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooLockCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\LockableTrait; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php index 5e40caf2d4795..e9147352cb662 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooOptCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseLowercaseCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseLowercaseCommand.php index b5db84ea87cef..7f0e2c2e6671c 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseLowercaseCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseLowercaseCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; class FooSameCaseLowercaseCommand extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseUppercaseCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseUppercaseCommand.php index ad8117332ec09..570726897dd06 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseUppercaseCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSameCaseUppercaseCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; class FooSameCaseUppercaseCommand extends Command diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php index 1d69908aeb965..72b389a674560 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php index fcce9bb51a28d..9867a07a59fb7 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooWithoutAliasCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooWithoutAliasCommand.php index e3c3c0b3c7e3b..268d0b3906da6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FooWithoutAliasCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooWithoutAliasCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php index d73b7d48b324b..9405b091707a6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php index 5cea01bd5ead7..8fe7c07712888 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure has single blank line at start when using block element +//Ensure has single blank line at start when using block element return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->caution('Lorem ipsum dolor sit amet'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php index 34e03df1ebe5a..e5c700d60eb56 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure has single blank line between titles and blocks +//Ensure has single blank line between titles and blocks return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->title('Title'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php index 16016ecf488f4..3111873ddde6c 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure that all lines are aligned to the begin of the first line in a very long line block +//Ensure that all lines are aligned to the begin of the first line in a very long line block return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->block( diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php index b3515dade649c..3ed897def42ce 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php index a4b4114d602c6..8c458ae764dc3 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php index 98cf1441058ed..9bcc68f69e2c5 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php index 8a8d2da781c89..a893a48bf248f 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php index b7fa882767235..68402cd408a2d 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php index 23916de089360..66e8179638821 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php index 1b9166149ba33..311e6b3928478 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure symfony style helper methods handle trailing backslashes properly when decorating user texts +//Ensure symfony style helper methods handle trailing backslashes properly when decorating user texts return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php index 89ea41ed8446e..d4afa45cf37c4 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Helper\TableSeparator; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php index 8568b0a7ef4fb..e44b18b76654d 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php @@ -1,20 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Helper\TableCell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure formatting tables when using multiple headers with TableCell +//Ensure formatting tables when using multiple headers with TableCell return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->horizontalTable(['a', 'b', 'c', 'd'], [[1, 2, 3], [4, 5], [7, 8, 9]]); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php index 655e46336a382..a16ad505d2bc4 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure has single blank line between blocks +//Ensure has single blank line between blocks return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->warning('Warning'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php index db438923a9cea..6b47969eeeba6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php index d6971e5daa201..8460e7ececf37 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure texts with emojis don't make longer lines than expected +//Ensure texts with emojis don't make longer lines than expected return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->success('Lorem ipsum dolor sit amet'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php index 861d118b0c0fc..1070394a89726 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php index ece15fabd50de..e6228fe0ba423 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php index 473fe017c36ec..99253a6c08a83 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure has single blank line between two titles +//Ensure has single blank line between two titles return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->title('First title'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php index 457e28a9c0868..3b215c7f2c5a6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure has single blank line after any text and a title +//Ensure has single blank line after any text and a title return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); @@ -27,17 +18,17 @@ $output->write(''); $output->title('Third title'); - // Ensure edge case by appending empty strings to history: + //Ensure edge case by appending empty strings to history: $output->write('Lorem ipsum dolor sit amet'); - $output->write(new ArrayIterator(['', '', ''])); + $output->write(new \ArrayIterator(['', '', ''])); $output->title('Fourth title'); - // Ensure have manual control over number of blank lines: + //Ensure have manual control over number of blank lines: $output->writeln('Lorem ipsum dolor sit amet'); - $output->writeln(new ArrayIterator(['', ''])); // Should append an extra blank line + $output->writeln(new \ArrayIterator(['', ''])); //Should append an extra blank line $output->title('Fifth title'); $output->writeln('Lorem ipsum dolor sit amet'); - $output->newLine(2); // Should append an extra blank line + $output->newLine(2); //Should append an extra blank line $output->title('Fifth title'); }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php index 16a472d662855..6fba5737fce39 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure has proper line ending before outputting a text block like with SymfonyStyle::listing() or SymfonyStyle::text() +//Ensure has proper line ending before outputting a text block like with SymfonyStyle::listing() or SymfonyStyle::text() return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); @@ -23,7 +14,7 @@ 'consectetur adipiscing elit', ]); - // Even using write: + //Even using write: $output->write('Lorem ipsum dolor sit amet'); $output->listing([ 'Lorem ipsum dolor sit amet', diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php index 245ee299c362e..3278f6ea05b12 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure has proper blank line after text block when using a block like with SymfonyStyle::success +//Ensure has proper blank line after text block when using a block like with SymfonyStyle::success return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php index 5edcbe46bda07..037c6ab6b3fe5 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure questions do not output anything when input is non-interactive +//Ensure questions do not output anything when input is non-interactive return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->title('Title'); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php index def8dd3f19533..fe9d484d252b3 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php @@ -1,20 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Helper\TableCell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure formatting tables when using multiple headers with TableCell +//Ensure formatting tables when using multiple headers with TableCell return function (InputInterface $input, OutputInterface $output) { $headers = [ [new TableCell('Main table title', ['colspan' => 3])], diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php index dca3fe6143661..73af4ae1e2614 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure that all lines are aligned to the begin of the first line in a multi-line block +//Ensure that all lines are aligned to the begin of the first line in a multi-line block return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->block(['Custom block', 'Second custom block line'], 'CUSTOM', 'fg=white;bg=green', 'X ', true); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php index b2c25b7717016..3c9c744050185 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -// Ensure that questions have the expected outputs +//Ensure that questions have the expected outputs return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $stream = fopen('php://memory', 'r+', false); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php index 55736eee77895..6487bc3b1fbb2 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; @@ -17,7 +8,7 @@ return function (InputInterface $input, OutputInterface $output) { $style = new SymfonyStyle($input, $output); - foreach ($style->progressIterate(range(1, 10)) as $step) { + foreach ($style->progressIterate(\range(1, 10)) as $step) { // noop } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php b/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php index 116261d40becf..cc3967c064820 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php b/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php index fc4b0389b43a8..3b8dcb2d2eac3 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/TestCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/TestCommand.php index f5e04946815f6..1d2b45af10a96 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/TestCommand.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/TestCommand.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php b/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php index 6b33210c216e5..12cf744eaffd9 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - use Symfony\Component\Console\Command\SignalableCommandInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -17,14 +8,14 @@ $vendor = __DIR__; while (!file_exists($vendor.'/vendor')) { - $vendor = dirname($vendor); + $vendor = \dirname($vendor); } require $vendor.'/vendor/autoload.php'; (new class() extends SingleCommandApplication implements SignalableCommandInterface { public function getSubscribedSignals(): array { - return [\SIGINT]; + return [SIGINT]; } public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false @@ -32,7 +23,7 @@ public function handleSignal(int $signal, int|false $previousExitCode = 0): int| exit(0); } }) - ->setCode(function (InputInterface $input, OutputInterface $output) { + ->setCode(function(InputInterface $input, OutputInterface $output) { $this->getHelper('question') ->ask($input, $output, new ChoiceQuestion('😊', ['y'])); diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 4a560713e1d5d..4af12e34c0680 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -1845,17 +1845,17 @@ public static function provideRenderVerticalTests(): \Traversable yield 'Borderless style' => [ << [ << [ <<assertEquals(['foo1' => null, 'foo2' => 'default', 'foo3' => []], $definition->getArgumentDefaults(), '->getArgumentDefaults() return the default values for each argument'); @@ -397,13 +397,7 @@ public static function getGetSynopsisData() public function testGetShortSynopsis() { - $definition = new InputDefinition([ - new InputOption('foo'), - new InputOption('bar'), - new InputOption('deprecated'), - new InputOption('hidden'), - new InputArgument('cat'), - ]); + $definition = new InputDefinition([new InputOption('foo'), new InputOption('bar'), new InputArgument('cat')]); $this->assertEquals('[options] [--] []', $definition->getSynopsis(true), '->getSynopsis(true) groups options in [options]'); } From 54baa40fe89d1daacf2618a685d6b038d84a253b Mon Sep 17 00:00:00 2001 From: flkasper Date: Fri, 12 Apr 2024 01:00:34 +0200 Subject: [PATCH 10/15] [Console] Applied change suggestion in Command::writeDeprecationMessages --- .../Component/Console/Command/Command.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 6f99d7bff86d7..10e1368bb2b06 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -659,19 +659,12 @@ private function writeDeprecationMessages(InputDefinition $inputDefinition, Inpu $deprecationMessages = []; foreach ($inputDefinition->getOptions() as $inputOption) { if ($inputOption->isDeprecated()) { - try { - $optionName = $inputOption->getName(); - $optionValue = $input->getOption($optionName); - if (isset($optionValue) && $optionValue !== $inputOption->getDefault()) { - $optionShortcut = $inputOption->getShortcut(); - $deprecationMessages[] = sprintf( - 'The option "--%s%s" is deprecated.', - $optionName, - $optionShortcut === null ? '' : ('|-' . $optionShortcut) - ); - } - } catch (\InvalidArgumentException $exception) { - // option not used, ignore + $optionNames = ['--' . $inputOption->getName()]; + if (null !== $inputOption->getShortcut()) { + $optionNames[] = '-'.$inputOption->getShortcut(); + } + if ($input->hasParameterOption($optionNames, true)) { + $deprecationMessages[] = sprintf('The option "%s" is deprecated.', implode('|', $optionNames)); } } } From 9a9ab172f2fb95579293667a9d78287b3b64517b Mon Sep 17 00:00:00 2001 From: flkasper Date: Fri, 12 Apr 2024 01:17:10 +0200 Subject: [PATCH 11/15] [Console] Added suggested description prefix to deprecated options in TextDescriptor.php --- .../Component/Console/Descriptor/TextDescriptor.php | 8 ++++++-- .../Component/Console/Tests/Fixtures/command_5.txt | 2 +- .../Tests/Fixtures/command_5_with_hidden_options.txt | 2 +- .../Console/Tests/Fixtures/input_option_deprecated.txt | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 055c2aa44e601..1f6922193e29d 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -73,11 +73,15 @@ protected function describeInputOption(InputOption $option, array $options = []) $spacingWidth = $totalWidth - Helper::width($synopsis); + $synopsis = \sprintf('<%1$s>%2$s', $option->isDeprecated() ? 'fg=gray;' : 'info', $synopsis); + + $description = trim(($option->isDeprecated() ? '[deprecated] ' : '') . $option->getDescription()); + $this->writeText(\sprintf(' %s %s%s%s%s', - \sprintf('<%1$s>%2$s', $option->isDeprecated() ? 'fg=gray;' : 'info', $synopsis), + $synopsis, str_repeat(' ', $spacingWidth), // + 4 = 2 spaces before , 2 spaces after - preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()), + preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $description), $default, $option->isArray() ? ' (multiple values allowed)' : '' ), $options); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt index c0c164ce31b22..76b744b8874de 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5.txt @@ -5,7 +5,7 @@ descriptor:command5 [options] Options: - -y, --deprecated_option + -y, --deprecated_option [deprecated] Help: command 5 help diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt index 724d2ee943988..fcd03cd3c36cc 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_5_with_hidden_options.txt @@ -5,7 +5,7 @@ descriptor:command5 [options] Options: - -y, --deprecated_option + -y, --deprecated_option [deprecated] -z, --hidden_option Help: diff --git a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt index 32703f812337a..ea1cdc8e4a70c 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/input_option_deprecated.txt @@ -1 +1 @@ --o, --option_name deprecated option description +-o, --option_name [deprecated] deprecated option description From cda876fcb29816e0a67e9a9ad7fe5368f36734a3 Mon Sep 17 00:00:00 2001 From: flkasper Date: Sun, 14 Apr 2024 16:06:32 +0200 Subject: [PATCH 12/15] [Console] Apply suggestion & fixed coding standard of changes --- src/Symfony/Component/Console/Command/Command.php | 2 +- src/Symfony/Component/Console/Descriptor/TextDescriptor.php | 2 +- src/Symfony/Component/Console/Input/InputOption.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 10e1368bb2b06..45fb6175a2948 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -659,7 +659,7 @@ private function writeDeprecationMessages(InputDefinition $inputDefinition, Inpu $deprecationMessages = []; foreach ($inputDefinition->getOptions() as $inputOption) { if ($inputOption->isDeprecated()) { - $optionNames = ['--' . $inputOption->getName()]; + $optionNames = ['--'.$inputOption->getName()]; if (null !== $inputOption->getShortcut()) { $optionNames[] = '-'.$inputOption->getShortcut(); } diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 1f6922193e29d..196201e63a44b 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -75,7 +75,7 @@ protected function describeInputOption(InputOption $option, array $options = []) $synopsis = \sprintf('<%1$s>%2$s', $option->isDeprecated() ? 'fg=gray;' : 'info', $synopsis); - $description = trim(($option->isDeprecated() ? '[deprecated] ' : '') . $option->getDescription()); + $description = trim(($option->isDeprecated() ? '[deprecated] ' : '').$option->getDescription()); $this->writeText(\sprintf(' %s %s%s%s%s', $synopsis, diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index c84252ee8eb47..2dcbeccc227e9 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -56,7 +56,7 @@ class InputOption public const DEPRECATED = 32; /** - * The option allows to hide command option from help. + * Hide the option from command descriptors. */ public const HIDDEN = 64; From c615abec394d1eb74eabc032876e9ce253b1ef45 Mon Sep 17 00:00:00 2001 From: FK Date: Mon, 26 Aug 2024 22:18:49 +0200 Subject: [PATCH 13/15] Apply suggestions from code review Co-authored-by: Nicolas Grekas --- src/Symfony/Component/Console/Command/Command.php | 4 ++-- .../Component/Console/Descriptor/MarkdownDescriptor.php | 3 +-- src/Symfony/Component/Console/Tests/Input/InputOptionTest.php | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 45fb6175a2948..f3b298a30c6f0 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -664,11 +664,11 @@ private function writeDeprecationMessages(InputDefinition $inputDefinition, Inpu $optionNames[] = '-'.$inputOption->getShortcut(); } if ($input->hasParameterOption($optionNames, true)) { - $deprecationMessages[] = sprintf('The option "%s" is deprecated.', implode('|', $optionNames)); + $deprecationMessages[] = \sprintf('The option "%s" is deprecated.', implode('|', $optionNames)); } } } - if (!empty($deprecationMessages)) { + if ($deprecationMessages) { /** @var FormatterHelper $formatter */ $formatter = $this->getHelper('formatter'); $output->writeln($formatter->formatBlock($deprecationMessages, 'fg=black;bg=yellow', true)); diff --git a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php index 5b819ae394dfc..2d825c2b4f104 100644 --- a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php @@ -86,8 +86,7 @@ protected function describeInputDefinition(InputDefinition $definition, array $o } } - $inputOptions = $this->removeHiddenOptions($definition->getOptions(), $options); - if (!empty($inputOptions)) { + if ($inputOptions = $this->removeHiddenOptions($definition->getOptions(), $options)) { if ($showArguments) { $this->write("\n\n"); } diff --git a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php index e70a8caf60223..ee77994df1566 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -143,7 +143,7 @@ public function testInvalidMode(?int $mode, string $message) public static function privideInvalidModeData() { yield 'negative mode' => [-1, 'Option mode "-1" is not valid.']; - yield 'invalid bit mask value' => [InputOption::HIDDEN << 1, sprintf('Option mode "%d" is not valid.', InputOption::HIDDEN << 1)]; + yield 'invalid bit mask value' => [InputOption::HIDDEN << 1, \sprintf('Option mode "%d" is not valid.', InputOption::HIDDEN << 1)]; } public function testEmptyNameIsInvalid() From 6602bb478b264400c2d80dbe75154d5a4c7e49a3 Mon Sep 17 00:00:00 2001 From: flkasper Date: Sat, 7 Sep 2024 22:35:31 +0200 Subject: [PATCH 14/15] Cleanup after rebase --- src/Symfony/Component/Console/Helper/ProgressIndicator.php | 1 - src/Symfony/Component/Console/Input/InputOption.php | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/ProgressIndicator.php b/src/Symfony/Component/Console/Helper/ProgressIndicator.php index 30baff8f24392..d06897d8543a2 100644 --- a/src/Symfony/Component/Console/Helper/ProgressIndicator.php +++ b/src/Symfony/Component/Console/Helper/ProgressIndicator.php @@ -54,7 +54,6 @@ public function __construct( private int $indicatorChangeInterval = 100, ?array $indicatorValues = null, ) { - $format ??= $this->determineBestFormat(); $indicatorValues ??= ['-', '\\', '|', '/']; $indicatorValues = array_values($indicatorValues); diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 2dcbeccc227e9..e2a433875ea37 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -90,7 +90,7 @@ public function __construct( $name = substr($name, 2); } - if (!$name) { + if (empty($name)) { throw new InvalidArgumentException('An option name cannot be empty.'); } @@ -113,8 +113,8 @@ public function __construct( if (null === $mode) { $mode = self::VALUE_NONE; - } elseif ($mode >= (self::LARGEST_MODE_FLAG << 1) || $mode < 1) { - throw new InvalidArgumentException(\sprintf('Option mode "%s" is not valid.', $mode)); + } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) { + throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); } $this->name = $name; From 05ad7d47fdb2c3be1d4d979afb43bb730a942a7b Mon Sep 17 00:00:00 2001 From: flkasper Date: Sat, 7 Sep 2024 22:39:18 +0200 Subject: [PATCH 15/15] Apply cs patch --- src/Symfony/Component/Console/Input/InputOption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index e2a433875ea37..ee5f432318d48 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -114,7 +114,7 @@ public function __construct( if (null === $mode) { $mode = self::VALUE_NONE; } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) { - throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); + throw new InvalidArgumentException(\sprintf('Option mode "%s" is not valid.', $mode)); } $this->name = $name;