diff --git a/Command/Command.php b/Command/Command.php index 0a3f4b788..434c79049 100644 --- a/Command/Command.php +++ b/Command/Command.php @@ -252,7 +252,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) * * @return int The command exit code * - * @throws \Exception When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}. + * @throws ExceptionInterface When input binding fails. Bypass this by calling {@link ignoreValidationErrors()}. * * @see setCode() * @see execute() @@ -442,7 +442,7 @@ public function getNativeDefinition(): InputDefinition * * @return $this */ - public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null, /*array|\Closure $suggestedValues = null*/): static + public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = null */): static { $suggestedValues = 5 <= \func_num_args() ? func_get_arg(4) : []; if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) { @@ -466,7 +466,7 @@ public function addArgument(string $name, int $mode = null, string $description * * @return $this */ - public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null, /*array|\Closure $suggestedValues = []*/): static + public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { $suggestedValues = 6 <= \func_num_args() ? func_get_arg(5) : []; if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) { diff --git a/Command/CompleteCommand.php b/Command/CompleteCommand.php index 404be4650..150837a99 100644 --- a/Command/CompleteCommand.php +++ b/Command/CompleteCommand.php @@ -78,15 +78,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int { try { // uncomment when a bugfix or BC break has been introduced in the shell completion scripts - //$version = $input->getOption('symfony'); - //if ($version && version_compare($version, 'x.y', '>=')) { + // $version = $input->getOption('symfony'); + // if ($version && version_compare($version, 'x.y', '>=')) { // $message = sprintf('Completion script version is not supported ("%s" given, ">=x.y" required).', $version); // $this->log($message); // $output->writeln($message.' Install the Symfony completion script again by using the "completion" command.'); // return 126; - //} + // } $shell = $input->getOption('shell'); if (!$shell) { diff --git a/Command/LazyCommand.php b/Command/LazyCommand.php index cb4d7f245..58cbb770a 100644 --- a/Command/LazyCommand.php +++ b/Command/LazyCommand.php @@ -114,7 +114,7 @@ public function getNativeDefinition(): InputDefinition * * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion */ - public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null, /*array|\Closure $suggestedValues = []*/): static + public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { $suggestedValues = 5 <= \func_num_args() ? func_get_arg(4) : []; $this->getCommand()->addArgument($name, $mode, $description, $default, $suggestedValues); @@ -127,7 +127,7 @@ public function addArgument(string $name, int $mode = null, string $description * * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion */ - public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null, /*array|\Closure $suggestedValues = []*/): static + public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { $suggestedValues = 6 <= \func_num_args() ? func_get_arg(5) : []; $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default, $suggestedValues); diff --git a/Helper/QuestionHelper.php b/Helper/QuestionHelper.php index 159330fd2..3fae76b26 100644 --- a/Helper/QuestionHelper.php +++ b/Helper/QuestionHelper.php @@ -24,6 +24,7 @@ use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Terminal; + use function Symfony\Component\String\s; /** diff --git a/Helper/Table.php b/Helper/Table.php index 0f8f6bd36..dcae7e711 100644 --- a/Helper/Table.php +++ b/Helper/Table.php @@ -674,7 +674,7 @@ private function fillNextRows(array $rows, int $line): array { $unmergedRows = []; foreach ($rows[$line] as $column => $cell) { - if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !$cell instanceof \Stringable) { + if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !$cell instanceof \Stringable) { throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell))); } if ($cell instanceof TableCell && $cell->getRowspan() > 1) { diff --git a/Logger/ConsoleLogger.php b/Logger/ConsoleLogger.php index 8d028ac8e..961b8cc9e 100644 --- a/Logger/ConsoleLogger.php +++ b/Logger/ConsoleLogger.php @@ -106,7 +106,7 @@ private function interpolate(string $message, array $context): string $replacements = []; foreach ($context as $key => $val) { - if (null === $val || is_scalar($val) || $val instanceof \Stringable) { + if (null === $val || \is_scalar($val) || $val instanceof \Stringable) { $replacements["{{$key}}"] = $val; } elseif ($val instanceof \DateTimeInterface) { $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339); diff --git a/Resources/completion.bash b/Resources/completion.bash index c5e89c3c2..fba46070c 100644 --- a/Resources/completion.bash +++ b/Resources/completion.bash @@ -13,9 +13,11 @@ _sf_{{ COMMAND_NAME }}() { # for an alias, get the real script behind it if [[ $(type -t $sf_cmd) == "alias" ]]; then sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/") + else + sf_cmd=$(type -p $sf_cmd) fi - if [ ! -f "$sf_cmd" ]; then + if [ ! -x "$sf_cmd" ]; then return 1 fi diff --git a/Style/SymfonyStyle.php b/Style/SymfonyStyle.php index 5e0aabb6e..f13c313d3 100644 --- a/Style/SymfonyStyle.php +++ b/Style/SymfonyStyle.php @@ -422,18 +422,18 @@ private function autoPrependBlock(): void $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); if (!isset($chars[0])) { - $this->newLine(); //empty history, so we should start with a new line. + $this->newLine(); // empty history, so we should start with a new line. return; } - //Prepend new line for each non LF chars (This means no blank line was output before) + // Prepend new line for each non LF chars (This means no blank line was output before) $this->newLine(2 - substr_count($chars, "\n")); } private function autoPrependText(): void { $fetched = $this->bufferedOutput->fetch(); - //Prepend new line if last char isn't EOL: + // Prepend new line if last char isn't EOL: if (!str_ends_with($fetched, "\n")) { $this->newLine(); } diff --git a/Tests/Command/CompleteCommandTest.php b/Tests/Command/CompleteCommandTest.php index 87c64504b..fe0cf1276 100644 --- a/Tests/Command/CompleteCommandTest.php +++ b/Tests/Command/CompleteCommandTest.php @@ -139,7 +139,7 @@ public function configure(): void $this->setName('hello') ->setAliases(['ahoy']) ->addArgument('name', InputArgument::REQUIRED) - ; + ; } public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void diff --git a/Tests/Formatter/OutputFormatterTest.php b/Tests/Formatter/OutputFormatterTest.php index 0c7696345..62db3e9e1 100644 --- a/Tests/Formatter/OutputFormatterTest.php +++ b/Tests/Formatter/OutputFormatterTest.php @@ -283,7 +283,7 @@ public function testContentWithLineBreaks() some text EOF - )); + )); $this->assertEquals(<<some text EOF - )); + )); $this->assertEquals(<< EOF - )); + )); $this->assertEquals(<< EOF - )); + )); } public function testFormatAndWrap() diff --git a/Tests/Helper/SymfonyQuestionHelperTest.php b/Tests/Helper/SymfonyQuestionHelperTest.php index 7877aabaa..72c3f879f 100644 --- a/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/Tests/Helper/SymfonyQuestionHelperTest.php @@ -162,7 +162,7 @@ public function testChoiceQuestionPadding() [łabądź] baz > EOT - , $output, true); + , $output, true); } public function testChoiceQuestionCustomPrompt() @@ -181,7 +181,7 @@ public function testChoiceQuestionCustomPrompt() [0] foo >ccc> EOT - , $output, true); + , $output, true); } protected function getInputStream($input) diff --git a/Tests/Tester/CommandTesterTest.php b/Tests/Tester/CommandTesterTest.php index 388a5249e..d3c644340 100644 --- a/Tests/Tester/CommandTesterTest.php +++ b/Tests/Tester/CommandTesterTest.php @@ -237,8 +237,7 @@ public function testErrorOutput() $command->addArgument('foo'); $command->setCode(function ($input, $output) { $output->getErrorOutput()->write('foo'); - } - ); + }); $tester = new CommandTester($command); $tester->execute(