From 656d546353cac3b2c4f4c1116ca5a3e712166ce7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 2 Apr 2026 15:43:53 +0200 Subject: [PATCH 1/9] [Console] Fix shell completion when SHELL_VERBOSITY=-1 --- Resources/completion.bash | 2 +- Resources/completion.fish | 2 +- Resources/completion.zsh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/completion.bash b/Resources/completion.bash index 2befe76cb..a32338e18 100644 --- a/Resources/completion.bash +++ b/Resources/completion.bash @@ -54,7 +54,7 @@ _sf_{{ COMMAND_NAME }}() { done local sfcomplete - if sfcomplete=$(${completecmd[@]} 2>&1); then + if sfcomplete=$(SHELL_VERBOSITY=0 ${completecmd[@]} 2>&1); then local quote suggestions quote=${cur:0:1} diff --git a/Resources/completion.fish b/Resources/completion.fish index 1c34292ae..d2309b36f 100644 --- a/Resources/completion.fish +++ b/Resources/completion.fish @@ -19,7 +19,7 @@ function _sf_{{ COMMAND_NAME }} set completecmd $completecmd "-c$c" - set sfcomplete ($completecmd) + set sfcomplete (env SHELL_VERBOSITY=0 $completecmd) for i in $sfcomplete echo $i diff --git a/Resources/completion.zsh b/Resources/completion.zsh index ff76fe5fa..eabeefb50 100644 --- a/Resources/completion.zsh +++ b/Resources/completion.zsh @@ -59,7 +59,7 @@ _sf_{{ COMMAND_NAME }}() { fi # Use eval to handle any environment variables and such - out=$(eval ${requestComp} 2>/dev/null) + out=$(eval SHELL_VERBOSITY=0 ${requestComp} 2>/dev/null) while IFS='\n' read -r comp; do if [ -n "$comp" ]; then From 45d4e67a5bca1496235e24ac5f7a189056b04dd2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 6 Apr 2026 11:26:53 +0200 Subject: [PATCH 2/9] Add deprecationTrigger ignoreUndefinedTriggers="true" in phpunit.xml.dist files --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a3dd340ba..ae62ad561 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,7 +20,7 @@ - + trigger_deprecation Doctrine\Deprecations\Deprecation::trigger Doctrine\Deprecations\Deprecation::triggerIfCalledFromOutside From a61f29ef092e739d961bec03cd471adc4ff6a6bb Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 13 Apr 2026 14:48:23 +0200 Subject: [PATCH 3/9] [CS] Back config from 8.1 and apply heredoc_indentation rule --- Command/DumpCompletionCommand.php | 34 +- Command/HelpCommand.php | 12 +- Command/ListCommand.php | 18 +- Tests/Command/ListCommandTest.php | 62 +- Tests/Formatter/OutputFormatterTest.php | 60 +- Tests/Helper/OutputWrapperTest.php | 52 +- Tests/Helper/QuestionHelperTest.php | 20 +- Tests/Helper/SymfonyQuestionHelperTest.php | 20 +- Tests/Helper/TableTest.php | 1398 ++++++++++---------- 9 files changed, 838 insertions(+), 838 deletions(-) diff --git a/Command/DumpCompletionCommand.php b/Command/DumpCompletionCommand.php index 571425b88..281d3c43e 100644 --- a/Command/DumpCompletionCommand.php +++ b/Command/DumpCompletionCommand.php @@ -56,33 +56,33 @@ protected function configure(): void $this ->setHelp(<<%command.name% command dumps the shell completion script required -to use shell autocompletion (currently, {$supportedShells} completion are supported). + The %command.name% command dumps the shell completion script required + to use shell autocompletion (currently, {$supportedShells} completion are supported). -Static installation -------------------- + Static installation + ------------------- -Dump the script to a global completion file and restart your shell: + Dump the script to a global completion file and restart your shell: - %command.full_name% {$shell} | sudo tee {$completionFile} + %command.full_name% {$shell} | sudo tee {$completionFile} -Or dump the script to a local file and source it: + Or dump the script to a local file and source it: - %command.full_name% {$shell} > completion.sh + %command.full_name% {$shell} > completion.sh - # source the file whenever you use the project - source completion.sh + # source the file whenever you use the project + source completion.sh - # or add this line at the end of your "{$rcFile}" file: - source /path/to/completion.sh + # or add this line at the end of your "{$rcFile}" file: + source /path/to/completion.sh -Dynamic installation --------------------- + Dynamic installation + -------------------- -Add this to the end of your shell configuration file (e.g. "{$rcFile}"): + Add this to the end of your shell configuration file (e.g. "{$rcFile}"): - eval "$({$fullCommand} completion {$shell})" -EOH + eval "$({$fullCommand} completion {$shell})" + EOH ) ->addArgument('shell', InputArgument::OPTIONAL, 'The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given', null, $this->getSupportedShells(...)) ->addOption('debug', null, InputOption::VALUE_NONE, 'Tail the completion debug log') diff --git a/Command/HelpCommand.php b/Command/HelpCommand.php index e6447b050..c1809da92 100644 --- a/Command/HelpCommand.php +++ b/Command/HelpCommand.php @@ -43,16 +43,16 @@ protected function configure() ]) ->setDescription('Display help for a command') ->setHelp(<<<'EOF' -The %command.name% command displays help for a given command: + The %command.name% command displays help for a given command: - %command.full_name% list + %command.full_name% list -You can also output the help in other formats by using the --format option: + You can also output the help in other formats by using the --format option: - %command.full_name% --format=xml list + %command.full_name% --format=xml list -To display the list of available commands, please use the list command. -EOF + To display the list of available commands, please use the list command. + EOF ) ; } diff --git a/Command/ListCommand.php b/Command/ListCommand.php index 5850c3d7b..77cf5b930 100644 --- a/Command/ListCommand.php +++ b/Command/ListCommand.php @@ -40,22 +40,22 @@ protected function configure() ]) ->setDescription('List commands') ->setHelp(<<<'EOF' -The %command.name% command lists all commands: + The %command.name% command lists all commands: - %command.full_name% + %command.full_name% -You can also display the commands for a specific namespace: + You can also display the commands for a specific namespace: - %command.full_name% test + %command.full_name% test -You can also output the information in other formats by using the --format option: + You can also output the information in other formats by using the --format option: - %command.full_name% --format=xml + %command.full_name% --format=xml -It's also possible to get raw list of commands (useful for embedding command runner): + It's also possible to get raw list of commands (useful for embedding command runner): - %command.full_name% --raw -EOF + %command.full_name% --raw + EOF ) ; } diff --git a/Tests/Command/ListCommandTest.php b/Tests/Command/ListCommandTest.php index 20dfa8d30..62b22011e 100644 --- a/Tests/Command/ListCommandTest.php +++ b/Tests/Command/ListCommandTest.php @@ -41,11 +41,11 @@ public function testExecuteListsCommandsWithRawOption() $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(['command' => $command->getName(), '--raw' => true]); $output = <<<'EOF' -completion Dump the shell completion script -help Display help for a command -list List commands + completion Dump the shell completion script + help Display help for a command + list List commands -EOF; + EOF; $this->assertEquals($output, $commandTester->getDisplay(true)); } @@ -58,9 +58,9 @@ public function testExecuteListsCommandsWithNamespaceArgument() $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(['command' => $command->getName(), 'namespace' => 'foo', '--raw' => true]); $output = <<<'EOF' -foo:bar The foo:bar command + foo:bar The foo:bar command -EOF; + EOF; $this->assertEquals($output, $commandTester->getDisplay(true)); } @@ -73,26 +73,26 @@ public function testExecuteListsCommandsOrder() $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(['command' => $command->getName()], ['decorated' => false]); $output = <<<'EOF' -Console Tool - -Usage: - command [options] [arguments] - -Options: - -h, --help Display help for the given command. When no command is given display help for the list command - -q, --quiet Do not output any message - -V, --version Display this application version - --ansi|--no-ansi Force (or disable --no-ansi) ANSI output - -n, --no-interaction Do not ask any interactive question - -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug - -Available commands: - completion Dump the shell completion script - help Display help for a command - list List commands - 0foo - 0foo:bar 0foo:bar command -EOF; + Console Tool + + Usage: + command [options] [arguments] + + Options: + -h, --help Display help for the given command. When no command is given display help for the list command + -q, --quiet Do not output any message + -V, --version Display this application version + --ansi|--no-ansi Force (or disable --no-ansi) ANSI output + -n, --no-interaction Do not ask any interactive question + -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + + Available commands: + completion Dump the shell completion script + help Display help for a command + list List commands + 0foo + 0foo:bar 0foo:bar command + EOF; $this->assertEquals($output, trim($commandTester->getDisplay(true))); } @@ -105,11 +105,11 @@ public function testExecuteListsCommandsOrderRaw() $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(['command' => $command->getName(), '--raw' => true]); $output = <<<'EOF' -completion Dump the shell completion script -help Display help for a command -list List commands -0foo:bar 0foo:bar command -EOF; + completion Dump the shell completion script + help Display help for a command + list List commands + 0foo:bar 0foo:bar command + EOF; $this->assertEquals($output, trim($commandTester->getDisplay(true))); } diff --git a/Tests/Formatter/OutputFormatterTest.php b/Tests/Formatter/OutputFormatterTest.php index 489108bd5..7f9aac914 100644 --- a/Tests/Formatter/OutputFormatterTest.php +++ b/Tests/Formatter/OutputFormatterTest.php @@ -307,49 +307,49 @@ public function testContentWithLineBreaks() $formatter = new OutputFormatter(true); $this->assertEquals(<<format(<<<'EOF' - -some text -EOF + + some text + EOF )); $this->assertEquals(<<format(<<<'EOF' -some text - -EOF + some text + + EOF )); $this->assertEquals(<<format(<<<'EOF' - -some text - -EOF + + some text + + EOF )); $this->assertEquals(<<format(<<<'EOF' - -some text -more text - -EOF + + some text + more text + + EOF )); } diff --git a/Tests/Helper/OutputWrapperTest.php b/Tests/Helper/OutputWrapperTest.php index 2ce15b6d4..9ad10a4e5 100644 --- a/Tests/Helper/OutputWrapperTest.php +++ b/Tests/Helper/OutputWrapperTest.php @@ -35,18 +35,18 @@ public static function textProvider(): iterable 20, false, <<<'EOS' - Árvíztűrőtükörfúrógé - p https://github.com/symfony/symfony Lorem ipsum - dolor sit amet, - consectetur - adipiscing elit. - Praesent vestibulum - nulla quis urna - maximus porttitor. - Donec ullamcorper - risus at libero - ornare efficitur. - EOS, + Árvíztűrőtükörfúrógé + p https://github.com/symfony/symfony Lorem ipsum + dolor sit amet, + consectetur + adipiscing elit. + Praesent vestibulum + nulla quis urna + maximus porttitor. + Donec ullamcorper + risus at libero + ornare efficitur. + EOS, ]; yield 'Allow URL cut' => [ @@ -54,20 +54,20 @@ public static function textProvider(): iterable 20, true, <<<'EOS' - Árvíztűrőtükörfúrógé - p - https://github.com/s - ymfony/symfony Lorem - ipsum dolor sit - amet, consectetur - adipiscing elit. - Praesent vestibulum - nulla quis urna - maximus porttitor. - Donec ullamcorper - risus at libero - ornare efficitur. - EOS, + Árvíztűrőtükörfúrógé + p + https://github.com/s + ymfony/symfony Lorem + ipsum dolor sit + amet, consectetur + adipiscing elit. + Praesent vestibulum + nulla quis urna + maximus porttitor. + Donec ullamcorper + risus at libero + ornare efficitur. + EOS, ]; } } diff --git a/Tests/Helper/QuestionHelperTest.php b/Tests/Helper/QuestionHelperTest.php index a49d60040..dc6c47fc2 100644 --- a/Tests/Helper/QuestionHelperTest.php +++ b/Tests/Helper/QuestionHelperTest.php @@ -466,14 +466,14 @@ public function testAskHiddenResponseNotTrimmed() public function testAskMultilineResponseWithEOF() { $essay = <<<'EOD' -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pretium lectus quis suscipit porttitor. Sed pretium bibendum vestibulum. + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pretium lectus quis suscipit porttitor. Sed pretium bibendum vestibulum. -Etiam accumsan, justo vitae imperdiet aliquet, neque est sagittis mauris, sed interdum massa leo id leo. + Etiam accumsan, justo vitae imperdiet aliquet, neque est sagittis mauris, sed interdum massa leo id leo. -Aliquam rhoncus, libero ac blandit convallis, est sapien hendrerit nulla, vitae aliquet tellus orci a odio. Aliquam gravida ante sit amet massa lacinia, ut condimentum purus venenatis. + Aliquam rhoncus, libero ac blandit convallis, est sapien hendrerit nulla, vitae aliquet tellus orci a odio. Aliquam gravida ante sit amet massa lacinia, ut condimentum purus venenatis. -Vivamus et erat dictum, euismod neque in, laoreet odio. Aenean vitae tellus at leo vestibulum auctor id eget urna. -EOD; + Vivamus et erat dictum, euismod neque in, laoreet odio. Aenean vitae tellus at leo vestibulum auctor id eget urna. + EOD; $response = $this->getInputStream($essay); @@ -525,11 +525,11 @@ public function testAskMultilineResponseWithMultipleNewlinesAtEnd() public function testAskMultilineResponseWithWithCursorInMiddleOfSeekableInputStream() { $input = <<getInputStream($input); fseek($response, 8); diff --git a/Tests/Helper/SymfonyQuestionHelperTest.php b/Tests/Helper/SymfonyQuestionHelperTest.php index c31a9106d..c14f6d086 100644 --- a/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/Tests/Helper/SymfonyQuestionHelperTest.php @@ -155,12 +155,12 @@ public function testChoiceQuestionPadding() ); $this->assertOutputContains(<< -EOT + qqq: + [foo ] foo + [żółw ] bar + [łabądź] baz + > + EOT , $output, true); } @@ -176,10 +176,10 @@ public function testChoiceQuestionCustomPrompt() ); $this->assertOutputContains(<<ccc> -EOT + qqq: + [0] foo + >ccc> + EOT , $output, true); } diff --git a/Tests/Helper/TableTest.php b/Tests/Helper/TableTest.php index 5dcdc64c5..12138bb8f 100644 --- a/Tests/Helper/TableTest.php +++ b/Tests/Helper/TableTest.php @@ -103,16 +103,16 @@ public static function renderProvider() $books, 'default', <<<'TABLE' -+---------------+--------------------------+------------------+ -| ISBN | Title | Author | -+---------------+--------------------------+------------------+ -| 99921-58-10-7 | Divine Comedy | Dante Alighieri | -| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | -| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | -| 80-902734-1-6 | And Then There Were None | Agatha Christie | -+---------------+--------------------------+------------------+ - -TABLE, + +---------------+--------------------------+------------------+ + | ISBN | Title | Author | + +---------------+--------------------------+------------------+ + | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | + | 80-902734-1-6 | And Then There Were None | Agatha Christie | + +---------------+--------------------------+------------------+ + + TABLE, ], [ ['ISBN', 'Title', 'Author'], @@ -148,16 +148,16 @@ public static function renderProvider() $books, 'box', <<<'TABLE' -┌───────────────┬──────────────────────────┬──────────────────┐ -│ ISBN │ Title │ Author │ -├───────────────┼──────────────────────────┼──────────────────┤ -│ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │ -│ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens │ -│ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien │ -│ 80-902734-1-6 │ And Then There Were None │ Agatha Christie │ -└───────────────┴──────────────────────────┴──────────────────┘ - -TABLE, + ┌───────────────┬──────────────────────────┬──────────────────┐ + │ ISBN │ Title │ Author │ + ├───────────────┼──────────────────────────┼──────────────────┤ + │ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │ + │ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens │ + │ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien │ + │ 80-902734-1-6 │ And Then There Were None │ Agatha Christie │ + └───────────────┴──────────────────────────┴──────────────────┘ + + TABLE, ], [ ['ISBN', 'Title', 'Author'], @@ -170,17 +170,17 @@ public static function renderProvider() ], 'box-double', <<<'TABLE' -╔═══════════════╤══════════════════════════╤══════════════════╗ -║ ISBN │ Title │ Author ║ -╠═══════════════╪══════════════════════════╪══════════════════╣ -║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║ -║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║ -╟───────────────┼──────────────────────────┼──────────────────╢ -║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║ -║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║ -╚═══════════════╧══════════════════════════╧══════════════════╝ - -TABLE, + ╔═══════════════╤══════════════════════════╤══════════════════╗ + ║ ISBN │ Title │ Author ║ + ╠═══════════════╪══════════════════════════╪══════════════════╣ + ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║ + ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║ + ╟───────────────┼──────────────────────────┼──────────────────╢ + ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║ + ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║ + ╚═══════════════╧══════════════════════════╧══════════════════╝ + + TABLE, ], [ ['ISBN', 'Title'], @@ -192,16 +192,16 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+---------------+--------------------------+------------------+ -| ISBN | Title | | -+---------------+--------------------------+------------------+ -| 99921-58-10-7 | Divine Comedy | Dante Alighieri | -| 9971-5-0210-0 | | | -| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | -| 80-902734-1-6 | And Then There Were None | Agatha Christie | -+---------------+--------------------------+------------------+ - -TABLE, + +---------------+--------------------------+------------------+ + | ISBN | Title | | + +---------------+--------------------------+------------------+ + | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + | 9971-5-0210-0 | | | + | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | + | 80-902734-1-6 | And Then There Were None | Agatha Christie | + +---------------+--------------------------+------------------+ + + TABLE, ], [ [], @@ -213,14 +213,14 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+---------------+--------------------------+------------------+ -| 99921-58-10-7 | Divine Comedy | Dante Alighieri | -| 9971-5-0210-0 | | | -| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | -| 80-902734-1-6 | And Then There Were None | Agatha Christie | -+---------------+--------------------------+------------------+ - -TABLE, + +---------------+--------------------------+------------------+ + | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + | 9971-5-0210-0 | | | + | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | + | 80-902734-1-6 | And Then There Were None | Agatha Christie | + +---------------+--------------------------+------------------+ + + TABLE, ], [ ['ISBN', 'Title', 'Author'], @@ -232,31 +232,31 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+---------------+----------------------------+-----------------+ -| ISBN | Title | Author | -+---------------+----------------------------+-----------------+ -| 99921-58-10-7 | Divine | Dante Alighieri | -| | Comedy | | -| 9971-5-0210-2 | Harry Potter | Rowling | -| | and the Chamber of Secrets | Joanne K. | -| 9971-5-0210-2 | Harry Potter | Rowling | -| | and the Chamber of Secrets | Joanne K. | -| 960-425-059-0 | The Lord of the Rings | J. R. R. | -| | | Tolkien | -+---------------+----------------------------+-----------------+ - -TABLE, + +---------------+----------------------------+-----------------+ + | ISBN | Title | Author | + +---------------+----------------------------+-----------------+ + | 99921-58-10-7 | Divine | Dante Alighieri | + | | Comedy | | + | 9971-5-0210-2 | Harry Potter | Rowling | + | | and the Chamber of Secrets | Joanne K. | + | 9971-5-0210-2 | Harry Potter | Rowling | + | | and the Chamber of Secrets | Joanne K. | + | 960-425-059-0 | The Lord of the Rings | J. R. R. | + | | | Tolkien | + +---------------+----------------------------+-----------------+ + + TABLE, ], [ ['ISBN', 'Title'], [], 'default', <<<'TABLE' -+------+-------+ -| ISBN | Title | -+------+-------+ + +------+-------+ + | ISBN | Title | + +------+-------+ -TABLE, + TABLE, ], [ [], @@ -272,14 +272,14 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+---------------+----------------------+-----------------+ -| ISBN | Title | Author | -+---------------+----------------------+-----------------+ -| 99921-58-10-7 | Divine Comedy | Dante Alighieri | -| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | -+---------------+----------------------+-----------------+ - -TABLE, + +---------------+----------------------+-----------------+ + | ISBN | Title | Author | + +---------------+----------------------+-----------------+ + | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + +---------------+----------------------+-----------------+ + + TABLE, ], 'Cell text with tags not used for Output styling' => [ ['ISBN', 'Title', 'Author'], @@ -289,14 +289,14 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+----------------------------------+----------------------+-----------------+ -| ISBN | Title | Author | -+----------------------------------+----------------------+-----------------+ -| 99921-58-10-700 | Divine Com | Dante Alighieri | -| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | -+----------------------------------+----------------------+-----------------+ - -TABLE, + +----------------------------------+----------------------+-----------------+ + | ISBN | Title | Author | + +----------------------------------+----------------------+-----------------+ + | 99921-58-10-700 | Divine Com | Dante Alighieri | + | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + +----------------------------------+----------------------+-----------------+ + + TABLE, ], 'Cell with colspan' => [ ['ISBN', 'Title', 'Author'], @@ -321,22 +321,22 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+-------------------------------+-------------------------------+-----------------------------+ -| ISBN | Title | Author | -+-------------------------------+-------------------------------+-----------------------------+ -| 99921-58-10-7 | Divine Comedy | Dante Alighieri | -+-------------------------------+-------------------------------+-----------------------------+ -| Divine Comedy(Dante Alighieri) | -+-------------------------------+-------------------------------+-----------------------------+ -| Arduino: A Quick-Start Guide | Mark Schmidt | -+-------------------------------+-------------------------------+-----------------------------+ -| 9971-5-0210-0 | A Tale of | -| | Two Cities | -+-------------------------------+-------------------------------+-----------------------------+ -| Cupìdĭtâte díctá âtquè pôrrò, tèmpórà exercitátìónèm mòdí ânìmí núllà nèmò vèl níhìl! | -+-------------------------------+-------------------------------+-----------------------------+ - -TABLE, + +-------------------------------+-------------------------------+-----------------------------+ + | ISBN | Title | Author | + +-------------------------------+-------------------------------+-----------------------------+ + | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + +-------------------------------+-------------------------------+-----------------------------+ + | Divine Comedy(Dante Alighieri) | + +-------------------------------+-------------------------------+-----------------------------+ + | Arduino: A Quick-Start Guide | Mark Schmidt | + +-------------------------------+-------------------------------+-----------------------------+ + | 9971-5-0210-0 | A Tale of | + | | Two Cities | + +-------------------------------+-------------------------------+-----------------------------+ + | Cupìdĭtâte díctá âtquè pôrrò, tèmpórà exercitátìónèm mòdí ânìmí núllà nèmò vèl níhìl! | + +-------------------------------+-------------------------------+-----------------------------+ + + TABLE, ], 'Cell after colspan contains new line break' => [ ['Foo', 'Bar', 'Baz'], @@ -348,14 +348,14 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+-----+-----+-----+ -| Foo | Bar | Baz | -+-----+-----+-----+ -| foo | baz | -| bar | qux | -+-----+-----+-----+ - -TABLE, + +-----+-----+-----+ + | Foo | Bar | Baz | + +-----+-----+-----+ + | foo | baz | + | bar | qux | + +-----+-----+-----+ + + TABLE, ], 'Cell after colspan contains multiple new lines' => [ ['Foo', 'Bar', 'Baz'], @@ -367,15 +367,15 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+-----+-----+------+ -| Foo | Bar | Baz | -+-----+-----+------+ -| foo | baz | -| bar | qux | -| | quux | -+-----+-----+------+ - -TABLE, + +-----+-----+------+ + | Foo | Bar | Baz | + +-----+-----+------+ + | foo | baz | + | bar | qux | + | | quux | + +-----+-----+------+ + + TABLE, ], 'Cell with rowspan' => [ ['ISBN', 'Title', 'Author'], @@ -393,20 +393,20 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+---------------+---------------+-----------------+ -| ISBN | Title | Author | -+---------------+---------------+-----------------+ -| 9971-5-0210-0 | Divine Comedy | Dante Alighieri | -| | | | -| | The Lord of | J. R. | -| | the Rings | R. Tolkien | -+---------------+---------------+-----------------+ -| 80-902734-1-6 | And Then | Agatha Christie | -| 80-902734-1-7 | There | Test | -| | Were None | | -+---------------+---------------+-----------------+ - -TABLE, + +---------------+---------------+-----------------+ + | ISBN | Title | Author | + +---------------+---------------+-----------------+ + | 9971-5-0210-0 | Divine Comedy | Dante Alighieri | + | | | | + | | The Lord of | J. R. | + | | the Rings | R. Tolkien | + +---------------+---------------+-----------------+ + | 80-902734-1-6 | And Then | Agatha Christie | + | 80-902734-1-7 | There | Test | + | | Were None | | + +---------------+---------------+-----------------+ + + TABLE, ], 'Cell with rowspan and colspan' => [ ['ISBN', 'Title', 'Author'], @@ -426,18 +426,18 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+------------------+---------+-----------------+ -| ISBN | Title | Author | -+------------------+---------+-----------------+ -| 9971-5-0210-0 | Dante Alighieri | -| | Charles Dickens | -+------------------+---------+-----------------+ -| Dante Alighieri | 9971-5-0210-0 | -| J. R. R. Tolkien | | -| J. R. R | | -+------------------+---------+-----------------+ - -TABLE, + +------------------+---------+-----------------+ + | ISBN | Title | Author | + +------------------+---------+-----------------+ + | 9971-5-0210-0 | Dante Alighieri | + | | Charles Dickens | + +------------------+---------+-----------------+ + | Dante Alighieri | 9971-5-0210-0 | + | J. R. R. Tolkien | | + | J. R. R | | + +------------------+---------+-----------------+ + + TABLE, ], 'Cell with rowspan and colspan contains new line break' => [ ['ISBN', 'Title', 'Author'], @@ -461,26 +461,26 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+-----------------+-------+-----------------+ -| ISBN | Title | Author | -+-----------------+-------+-----------------+ -| 9971 | Dante Alighieri | -| -5- | Charles Dickens | -| 021 | | -| 0-0 | | -+-----------------+-------+-----------------+ -| Dante Alighieri | 9971 | -| Charles Dickens | -5- | -| | 021 | -| | 0-0 | -+-----------------+-------+-----------------+ -| 9971 | Dante | -| -5- | Alighieri | -| 021 | | -| 0-0 | | -+-----------------+-------+-----------------+ - -TABLE, + +-----------------+-------+-----------------+ + | ISBN | Title | Author | + +-----------------+-------+-----------------+ + | 9971 | Dante Alighieri | + | -5- | Charles Dickens | + | 021 | | + | 0-0 | | + +-----------------+-------+-----------------+ + | Dante Alighieri | 9971 | + | Charles Dickens | -5- | + | | 021 | + | | 0-0 | + +-----------------+-------+-----------------+ + | 9971 | Dante | + | -5- | Alighieri | + | 021 | | + | 0-0 | | + +-----------------+-------+-----------------+ + + TABLE, ], 'Cell with rowspan and colspan without using TableSeparator' => [ ['ISBN', 'Title', 'Author'], @@ -498,20 +498,20 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+-----------------+-------+-----------------+ -| ISBN | Title | Author | -+-----------------+-------+-----------------+ -| 9971 | Dante Alighieri | -| -5- | Charles Dickens | -| 021 | | -| 0-0 | | -| Dante Alighieri | 9971 | -| Charles Dickens | -5- | -| | 021 | -| | 0-0 | -+-----------------+-------+-----------------+ - -TABLE, + +-----------------+-------+-----------------+ + | ISBN | Title | Author | + +-----------------+-------+-----------------+ + | 9971 | Dante Alighieri | + | -5- | Charles Dickens | + | 021 | | + | 0-0 | | + | Dante Alighieri | 9971 | + | Charles Dickens | -5- | + | | 021 | + | | 0-0 | + +-----------------+-------+-----------------+ + + TABLE, ], 'Cell with rowspan and colspan with separator inside a rowspan' => [ ['ISBN', 'Author'], @@ -525,15 +525,15 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+---------------+-----------------+ -| ISBN | Author | -+---------------+-----------------+ -| 9971-5-0210-0 | Dante Alighieri | -| |-----------------| -| | Charles Dickens | -+---------------+-----------------+ - -TABLE, + +---------------+-----------------+ + | ISBN | Author | + +---------------+-----------------+ + | 9971-5-0210-0 | Dante Alighieri | + | |-----------------| + | | Charles Dickens | + +---------------+-----------------+ + + TABLE, ], 'Multiple header lines' => [ [ @@ -543,13 +543,13 @@ public static function renderProvider() [], 'default', <<<'TABLE' -+------+-------+--------+ -| Main title | -+------+-------+--------+ -| ISBN | Title | Author | -+------+-------+--------+ + +------+-------+--------+ + | Main title | + +------+-------+--------+ + | ISBN | Title | Author | + +------+-------+--------+ -TABLE, + TABLE, ], 'Row with multiple cells' => [ [], @@ -563,11 +563,11 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+---+--+--+---+--+---+--+---+--+ -| 1 | 2 | 3 | 4 | -+---+--+--+---+--+---+--+---+--+ + +---+--+--+---+--+---+--+---+--+ + | 1 | 2 | 3 | 4 | + +---+--+--+---+--+---+--+---+--+ -TABLE, + TABLE, ], 'Coslpan and table cells with comment style' => [ [ @@ -586,15 +586,15 @@ public static function renderProvider() ], 'default', << 1' => [ @@ -766,15 +766,15 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+---------------+---------------+-------------------------------------------+ -| 978 | De Monarchia | Dante Alighieri | -| 99921-58-10-7 | Divine Comedy | spans multiple rows rows Dante Alighieri | -| | | spans multiple rows rows | -+---------------+---------------+-------------------------------------------+ -| test | tttt | -+---------------+---------------+-------------------------------------------+ - -TABLE + +---------------+---------------+-------------------------------------------+ + | 978 | De Monarchia | Dante Alighieri | + | 99921-58-10-7 | Divine Comedy | spans multiple rows rows Dante Alighieri | + | | | spans multiple rows rows | + +---------------+---------------+-------------------------------------------+ + | test | tttt | + +---------------+---------------+-------------------------------------------+ + + TABLE , true, ], @@ -821,15 +821,15 @@ public static function renderProvider() ], 'default', <<<'TABLE' -+----------------+---------------+---------------------+ -| ISBN | Title | Author | -+----------------+---------------+---------------------+ -| 978-0521567817 | De Monarchia | Dante Alighieri | -| 978-0804169127 | Divine Comedy | spans multiple rows | -| test | tttt | -+----------------+---------------+---------------------+ - -TABLE + +----------------+---------------+---------------------+ + | ISBN | Title | Author | + +----------------+---------------+---------------------+ + | 978-0521567817 | De Monarchia | Dante Alighieri | + | 978-0804169127 | Divine Comedy | spans multiple rows | + | test | tttt | + +----------------+---------------+---------------------+ + + TABLE , true, ], @@ -848,13 +848,13 @@ public function testRenderMultiByte() $expected = <<<'TABLE' -+------+ -| ■■ | -+------+ -| 1234 | -+------+ + +------+ + | ■■ | + +------+ + | 1234 | + +------+ -TABLE; + TABLE; $this->assertEquals($expected, $this->getOutputContent($output)); } @@ -868,11 +868,11 @@ public function testTableCellWithNumericIntValue() $expected = <<<'TABLE' -+-------+ -| 12345 | -+-------+ + +-------+ + | 12345 | + +-------+ -TABLE; + TABLE; $this->assertEquals($expected, $this->getOutputContent($output)); } @@ -886,11 +886,11 @@ public function testTableCellWithNumericFloatValue() $expected = <<<'TABLE' -+----------+ -| 12345.01 | -+----------+ + +----------+ + | 12345.01 | + +----------+ -TABLE; + TABLE; $this->assertEquals($expected, $this->getOutputContent($output)); } @@ -914,13 +914,13 @@ public function testStyle() $expected = <<<'TABLE' -....... -. Foo . -....... -. Bar . -....... + ....... + . Foo . + ....... + . Bar . + ....... -TABLE; + TABLE; $this->assertEquals($expected, $this->getOutputContent($output)); } @@ -941,17 +941,17 @@ public function testRowSeparator() $expected = <<<'TABLE' -+------+ -| Foo | -+------+ -| Bar1 | -+------+ -| Bar2 | -+------+ -| Bar3 | -+------+ - -TABLE; + +------+ + | Foo | + +------+ + | Bar1 | + +------+ + | Bar2 | + +------+ + | Bar3 | + +------+ + + TABLE; $this->assertEquals($expected, $this->getOutputContent($output)); @@ -970,17 +970,17 @@ public function testRenderMultiCalls() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1003,14 +1003,14 @@ public function testColumnStyle() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1049,14 +1049,14 @@ public function testColumnWidth() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1080,14 +1080,14 @@ public function testColumnWidths() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1110,19 +1110,19 @@ public function testSectionOutput() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1143,14 +1143,14 @@ public function testSectionOutputDoesntClearIfTableIsntRendered() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1173,19 +1173,19 @@ public function testSectionOutputWithoutDecoration() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1216,17 +1216,17 @@ public function testSectionOutputHandlesZeroRowsAfterRender() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1276,16 +1276,16 @@ public static function renderSetTitle() 'Page 1/2', 'default', <<<'TABLE' -+---------------+----------- Books --------+------------------+ -| ISBN | Title | Author | -+---------------+--------------------------+------------------+ -| 99921-58-10-7 | Divine Comedy | Dante Alighieri | -| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | -| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | -| 80-902734-1-6 | And Then There Were None | Agatha Christie | -+---------------+--------- Page 1/2 -------+------------------+ - -TABLE + +---------------+----------- Books --------+------------------+ + | ISBN | Title | Author | + +---------------+--------------------------+------------------+ + | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | + | 80-902734-1-6 | And Then There Were None | Agatha Christie | + +---------------+--------- Page 1/2 -------+------------------+ + + TABLE , true, ], @@ -1294,50 +1294,50 @@ public static function renderSetTitle() 'footer', 'default', <<<'TABLE' -+---------------+--- Multiline -header -here +------------------+ -| ISBN | Title | Author | -+---------------+--------------------------+------------------+ -| 99921-58-10-7 | Divine Comedy | Dante Alighieri | -| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | -| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | -| 80-902734-1-6 | And Then There Were None | Agatha Christie | -+---------------+---------- footer --------+------------------+ - -TABLE, + +---------------+--- Multiline + header + here +------------------+ + | ISBN | Title | Author | + +---------------+--------------------------+------------------+ + | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | + | 80-902734-1-6 | And Then There Were None | Agatha Christie | + +---------------+---------- footer --------+------------------+ + + TABLE, ], [ 'Books', 'Page 1/2', 'box', <<<'TABLE' -┌───────────────┬─────────── Books ────────┬──────────────────┐ -│ ISBN │ Title │ Author │ -├───────────────┼──────────────────────────┼──────────────────┤ -│ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │ -│ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens │ -│ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien │ -│ 80-902734-1-6 │ And Then There Were None │ Agatha Christie │ -└───────────────┴───────── Page 1/2 ───────┴──────────────────┘ - -TABLE, + ┌───────────────┬─────────── Books ────────┬──────────────────┐ + │ ISBN │ Title │ Author │ + ├───────────────┼──────────────────────────┼──────────────────┤ + │ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │ + │ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens │ + │ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien │ + │ 80-902734-1-6 │ And Then There Were None │ Agatha Christie │ + └───────────────┴───────── Page 1/2 ───────┴──────────────────┘ + + TABLE, ], [ 'Boooooooooooooooooooooooooooooooooooooooooooooooooooooooks', 'Page 1/999999999999999999999999999999999999999999999999999', 'default', <<<'TABLE' -+- Booooooooooooooooooooooooooooooooooooooooooooooooooooo... -+ -| ISBN | Title | Author | -+---------------+--------------------------+------------------+ -| 99921-58-10-7 | Divine Comedy | Dante Alighieri | -| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | -| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | -| 80-902734-1-6 | And Then There Were None | Agatha Christie | -+- Page 1/99999999999999999999999999999999999999999999999... -+ - -TABLE, + +- Booooooooooooooooooooooooooooooooooooooooooooooooooooo... -+ + | ISBN | Title | Author | + +---------------+--------------------------+------------------+ + | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | + | 80-902734-1-6 | And Then There Were None | Agatha Christie | + +- Page 1/99999999999999999999999999999999999999999999999... -+ + + TABLE, ], ]; } @@ -1353,12 +1353,12 @@ public function testSetTitleWithoutHeaders() ->render(); $expected = <<<'TABLE' -+-------- Reproducer --------+ -| Value | 123-456 | -| Some other value | 789-0 | -+------------------+---------+ + +-------- Reproducer --------+ + | Value | 123-456 | + | Some other value | 789-0 | + +------------------+---------+ -TABLE; + TABLE; $this->assertSame($expected, $this->getOutputContent($output)); } @@ -1378,16 +1378,16 @@ public function testColumnMaxWidths() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1414,15 +1414,15 @@ public function testColumnMaxWidthsHeaders() $expected = <<
assertEquals($expected, $this->getOutputContent($output)); } @@ -1437,12 +1437,12 @@ public function testColumnMaxWidthsWithTrailingBackslash() $expected = <<<'TABLE' -+-------+ -| 1234\ | -| 6 | -+-------+ + +-------+ + | 1234\ | + | 6 | + +-------+ -TABLE; + TABLE; $this->assertEquals($expected, $this->getOutputContent($output)); } @@ -1470,15 +1470,15 @@ public function testBoxedStyleWithColspan() $expected = <<
assertSame($expected, $this->getOutputContent($output)); } @@ -1488,37 +1488,37 @@ public static function provideRenderHorizontalTests() $headers = ['foo', 'bar', 'baz']; $rows = [['one', 'two', 'tree'], ['1', '2', '3']]; $expected = <<assertSame($expected, $this->getOutputContent($output)); } @@ -1611,19 +1611,19 @@ public static function provideRenderVerticalTests(): \Traversable yield 'With header for all' => [ << [ << [ << [ << [ << [ << [ << [ << [ << [ << [ << [ << [ << [ << [ << [ <<assertSame($expected, $this->getOutputContent($output)); } @@ -2038,12 +2038,12 @@ public function testGithubIssue52101HorizontalTrue() $table->render(); $this->assertSame(<<
getOutputContent($output) ); @@ -2067,14 +2067,14 @@ public function testGithubIssue52101HorizontalFalse() $table->render(); $this->assertSame(<<
getOutputContent($output) ); } @@ -2094,15 +2094,15 @@ public function testGithubIssue60038WidthOfCellWithEmoji() $table->render(); $this->assertSame(<<
getOutputContent($output) ); From 545cb3522d2ab46020c1bb8ecc3ebb7518a57186 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 13 Apr 2026 15:47:38 +0200 Subject: [PATCH 4/9] Backport some CS fixes from 7.4 --- Tests/Helper/SymfonyQuestionHelperTest.php | 12 ++-- Tests/Helper/TableTest.php | 72 ++++++++-------------- 2 files changed, 32 insertions(+), 52 deletions(-) diff --git a/Tests/Helper/SymfonyQuestionHelperTest.php b/Tests/Helper/SymfonyQuestionHelperTest.php index c14f6d086..99460a849 100644 --- a/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/Tests/Helper/SymfonyQuestionHelperTest.php @@ -160,8 +160,10 @@ public function testChoiceQuestionPadding() [żółw ] bar [łabądź] baz > - EOT - , $output, true); + EOT, + $output, + true + ); } public function testChoiceQuestionCustomPrompt() @@ -179,8 +181,10 @@ public function testChoiceQuestionCustomPrompt() qqq: [0] foo >ccc> - EOT - , $output, true); + EOT, + $output, + true + ); } protected function getInputStream($input) diff --git a/Tests/Helper/TableTest.php b/Tests/Helper/TableTest.php index 12138bb8f..93563294f 100644 --- a/Tests/Helper/TableTest.php +++ b/Tests/Helper/TableTest.php @@ -594,8 +594,7 @@ public static function renderProvider() | Dante Alighieri | J. R. R. Tolkien | J. R. R | +-----------------+------------------+---------+ - TABLE - , + TABLE, true, ], 'Row with formatted cells containing a newline' => [ @@ -623,8 +622,7 @@ public static function renderProvider() | bar | here | +-------+------------+ - TABLE - , + TABLE, true, ], 'TabeCellStyle with align. Also with rowspan and colspan > 1' => [ @@ -705,8 +703,7 @@ public static function renderProvider() | test | tttt | +---------------+---------------+-------------------------------------------+ - TABLE - , + TABLE, ], 'TabeCellStyle with fg,bg. Also with rowspan and colspan > 1' => [ [], @@ -774,8 +771,7 @@ public static function renderProvider() | test | tttt | +---------------+---------------+-------------------------------------------+ - TABLE - , + TABLE, true, ], 'TabeCellStyle with cellFormat. Also with rowspan and colspan > 1' => [ @@ -829,8 +825,7 @@ public static function renderProvider() | test | tttt | +----------------+---------------+---------------------+ - TABLE - , + TABLE, true, ], ]; @@ -1285,8 +1280,7 @@ public static function renderSetTitle() | 80-902734-1-6 | And Then There Were None | Agatha Christie | +---------------+--------- Page 1/2 -------+------------------+ - TABLE - , + TABLE, true, ], 'header contains multiple lines' => [ @@ -1623,8 +1617,7 @@ public static function provideRenderVerticalTests(): \Traversable | Price: 139.25 | +------------------------------+ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author', 'Price'], $books, ]; @@ -1643,8 +1636,7 @@ public static function provideRenderVerticalTests(): \Traversable | 139.25 | +----------------------+ - EOTXT - , + EOTXT, [], $books, ]; @@ -1658,8 +1650,7 @@ public static function provideRenderVerticalTests(): \Traversable | Price: 9.95 | +-------------------------+ - EOTXT - , + EOTXT, ['ISBN', 'Títle', 'Author', 'Price'], [ [ @@ -1685,8 +1676,7 @@ public static function provideRenderVerticalTests(): \Traversable | : 139.25 | +------------------------------+ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author'], $books, ]; @@ -1703,8 +1693,7 @@ public static function provideRenderVerticalTests(): \Traversable | baz: | +----------+ - EOTXT - , + EOTXT, ['foo', 'bar', 'baz'], [ ['one', 'two'], @@ -1724,8 +1713,7 @@ public static function provideRenderVerticalTests(): \Traversable | baz: 3 | +-----------+ - EOTXT - , + EOTXT, ['foo', 'bar', 'baz'], [ ['one', 'two', 'tree'], @@ -1749,8 +1737,7 @@ public static function provideRenderVerticalTests(): \Traversable | Price: 139.25 | +-------------------------+ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author', 'Price'], [ ['99921-58-10-7', 'Divine Comedy', 'Dante Alighieri', '9.95'], @@ -1770,8 +1757,7 @@ public static function provideRenderVerticalTests(): \Traversable | Author: Charles Dickens | +------------------------------+ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author'], [ ['99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'], @@ -1793,8 +1779,7 @@ public static function provideRenderVerticalTests(): \Traversable | Author: Charles Dickens | +---------------------------------------------------------------------------------------+ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author'], [ ['99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'], @@ -1825,8 +1810,7 @@ public static function provideRenderVerticalTests(): \Traversable | Lorem ipsum dolor sit amet, consectetur | +--------------------------------------------------------------------------------+ - EOTXT - , + EOTXT, [], [ [new TableCell('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor', ['colspan' => 3])], @@ -1857,8 +1841,7 @@ public static function provideRenderVerticalTests(): \Traversable Price: 139.25 ============================== - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author', 'Price'], $books, 'borderless', @@ -1876,8 +1859,7 @@ public static function provideRenderVerticalTests(): \Traversable Author: Charles Dickens Price: 139.25 - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author', 'Price'], $books, 'compact', @@ -1897,8 +1879,7 @@ public static function provideRenderVerticalTests(): \Traversable Price: 139.25 ------------------------------ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author', 'Price'], $books, 'symfony-style-guide', @@ -1918,8 +1899,7 @@ public static function provideRenderVerticalTests(): \Traversable │ Price: 139.25 │ └──────────────────────────────┘ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author', 'Price'], $books, 'box', @@ -1939,8 +1919,7 @@ public static function provideRenderVerticalTests(): \Traversable ║ Price: 139.25 ║ ╚══════════════════════════════╝ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author', 'Price'], $books, 'box-double', @@ -1960,8 +1939,7 @@ public static function provideRenderVerticalTests(): \Traversable | Price: 139.25 | +---------- Page 1/2 ----------+ - EOTXT - , + EOTXT, ['ISBN', 'Title', 'Author', 'Price'], $books, 'default', @@ -2043,8 +2021,7 @@ public function testGithubIssue52101HorizontalTrue() │ World │ 2 │ 4 │ └───────┴───┴───┘ - TABLE - , + TABLE, $this->getOutputContent($output) ); } @@ -2102,8 +2079,7 @@ public function testGithubIssue60038WidthOfCellWithEmoji() | And a very long line to show difference in previous lines | | +-----------------------------------------------------------+-----------------+ - TABLE - , + TABLE, $this->getOutputContent($output) ); } From 2f04c68868959c7fc2db8ff9be080528213fd077 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 13 Apr 2026 16:11:12 +0200 Subject: [PATCH 5/9] CS fixes - native_function_invocation & static_lambda --- Application.php | 8 +- Command/CompleteCommand.php | 2 +- Command/DumpCompletionCommand.php | 2 +- Command/HelpCommand.php | 2 +- Command/ListCommand.php | 2 +- Descriptor/MarkdownDescriptor.php | 6 +- Descriptor/TextDescriptor.php | 4 +- Helper/Dumper.php | 2 +- Helper/ProgressBar.php | 16 +-- Helper/ProgressIndicator.php | 8 +- Helper/QuestionHelper.php | 2 +- Input/Input.php | 2 +- Question/ConfirmationQuestion.php | 2 +- SignalRegistry/SignalMap.php | 2 +- Tests/ApplicationTest.php | 114 +++++++++--------- Tests/Command/CommandTest.php | 2 +- .../ContainerCommandLoaderTest.php | 12 +- .../FactoryCommandLoaderTest.php | 12 +- Tests/Helper/ProcessHelperTest.php | 2 +- Tests/Helper/ProgressBarTest.php | 8 +- Tests/Helper/QuestionHelperTest.php | 14 +-- Tests/Helper/SymfonyQuestionHelperTest.php | 2 +- Tests/Input/InputArgumentTest.php | 8 +- Tests/Input/InputOptionTest.php | 8 +- Tests/Question/QuestionTest.php | 14 +-- Tests/SignalRegistry/SignalRegistryTest.php | 18 +-- Tests/Tester/ApplicationTesterTest.php | 6 +- Tests/Tester/CommandTesterTest.php | 18 +-- 28 files changed, 149 insertions(+), 149 deletions(-) diff --git a/Application.php b/Application.php index b405c8318..a91154858 100644 --- a/Application.php +++ b/Application.php @@ -783,7 +783,7 @@ public function find(string $name) foreach ($abbrevs as $abbrev) { $maxLen = max(Helper::width($abbrev), $maxLen); } - $abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) { + $abbrevs = array_map(static function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) { if ($commandList[$cmd]->isHidden()) { unset($commands[array_search($cmd, $commands)]); @@ -898,7 +898,7 @@ protected function doRenderThrowable(\Throwable $e, OutputInterface $output): vo } if (str_contains($message, "@anonymous\0")) { - $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message); + $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', static fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message); } $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX; @@ -1078,7 +1078,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI } foreach ($commandSignals as $signal) { - $this->signalRegistry->register($signal, function (int $signal) use ($command): void { + $this->signalRegistry->register($signal, static function (int $signal) use ($command): void { $exitCode = $command->handleSignal($signal); // BC layer for Symfony <= 5 if (null === $exitCode) { @@ -1255,7 +1255,7 @@ private function findAlternatives(string $name, iterable $collection): array } } - $alternatives = array_filter($alternatives, fn ($lev) => $lev < 2 * $threshold); + $alternatives = array_filter($alternatives, static fn ($lev) => $lev < 2 * $threshold); ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE); return array_keys($alternatives); diff --git a/Command/CompleteCommand.php b/Command/CompleteCommand.php index 00b80f340..1af8bf7a2 100644 --- a/Command/CompleteCommand.php +++ b/Command/CompleteCommand.php @@ -161,7 +161,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->log('Suggestions:'); if ($options = $suggestions->getOptionSuggestions()) { - $this->log(' --'.implode(' --', array_map(fn ($o) => $o->getName(), $options))); + $this->log(' --'.implode(' --', array_map(static fn ($o) => $o->getName(), $options))); } elseif ($values = $suggestions->getValueSuggestions()) { $this->log(' '.implode(' ', $values)); } else { diff --git a/Command/DumpCompletionCommand.php b/Command/DumpCompletionCommand.php index 281d3c43e..088a89219 100644 --- a/Command/DumpCompletionCommand.php +++ b/Command/DumpCompletionCommand.php @@ -133,7 +133,7 @@ private function tailDebugLog(string $commandName, OutputInterface $output): voi touch($debugFile); } $process = new Process(['tail', '-f', $debugFile], null, null, null, 0); - $process->run(function (string $type, string $line) use ($output): void { + $process->run(static function (string $type, string $line) use ($output): void { $output->write($line); }); } diff --git a/Command/HelpCommand.php b/Command/HelpCommand.php index c1809da92..969722104 100644 --- a/Command/HelpCommand.php +++ b/Command/HelpCommand.php @@ -38,7 +38,7 @@ protected function configure() ->setName('help') ->setDefinition([ 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('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', static fn () => (new DescriptorHelper())->getFormats()), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), ]) ->setDescription('Display help for a command') diff --git a/Command/ListCommand.php b/Command/ListCommand.php index 77cf5b930..b6c446792 100644 --- a/Command/ListCommand.php +++ b/Command/ListCommand.php @@ -35,7 +35,7 @@ protected function configure() ->setDefinition([ new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, fn () => array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces())), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), - new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn () => (new DescriptorHelper())->getFormats()), + new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', static fn () => (new DescriptorHelper())->getFormats()), new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'), ]) ->setDescription('List commands') diff --git a/Descriptor/MarkdownDescriptor.php b/Descriptor/MarkdownDescriptor.php index 8b7075943..15fad8de4 100644 --- a/Descriptor/MarkdownDescriptor.php +++ b/Descriptor/MarkdownDescriptor.php @@ -106,7 +106,7 @@ protected function describeCommand(Command $command, array $options = []): void .str_repeat('-', Helper::width($command->getName()) + 2)."\n\n" .($command->getDescription() ? $command->getDescription()."\n\n" : '') .'### Usage'."\n\n" - .array_reduce($command->getAliases(), fn ($carry, $usage) => $carry.'* `'.$usage.'`'."\n") + .array_reduce($command->getAliases(), static fn ($carry, $usage) => $carry.'* `'.$usage.'`'."\n") ); return; @@ -119,7 +119,7 @@ protected function describeCommand(Command $command, array $options = []): void .str_repeat('-', Helper::width($command->getName()) + 2)."\n\n" .($command->getDescription() ? $command->getDescription()."\n\n" : '') .'### Usage'."\n\n" - .array_reduce(array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), fn ($carry, $usage) => $carry.'* `'.$usage.'`'."\n") + .array_reduce(array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), static fn ($carry, $usage) => $carry.'* `'.$usage.'`'."\n") ); if ($help = $command->getProcessedHelp()) { @@ -149,7 +149,7 @@ protected function describeApplication(Application $application, array $options } $this->write("\n\n"); - $this->write(implode("\n", array_map(fn ($commandName) => \sprintf('* [`%s`](#%s)', $commandName, str_replace(':', '', $description->getCommand($commandName)->getName())), $namespace['commands']))); + $this->write(implode("\n", array_map(static fn ($commandName) => \sprintf('* [`%s`](#%s)', $commandName, str_replace(':', '', $description->getCommand($commandName)->getName())), $namespace['commands']))); } foreach ($description->getCommands() as $command) { diff --git a/Descriptor/TextDescriptor.php b/Descriptor/TextDescriptor.php index 51c411f46..226d87aee 100644 --- a/Descriptor/TextDescriptor.php +++ b/Descriptor/TextDescriptor.php @@ -193,7 +193,7 @@ protected function describeApplication(Application $application, array $options } // calculate max. width based on available commands per namespace - $width = $this->getColumnWidth(array_merge(...array_values(array_map(fn ($namespace) => array_intersect($namespace['commands'], array_keys($commands)), array_values($namespaces))))); + $width = $this->getColumnWidth(array_merge(...array_values(array_map(static fn ($namespace) => array_intersect($namespace['commands'], array_keys($commands)), array_values($namespaces))))); if ($describedNamespace) { $this->writeText(\sprintf('Available commands for the "%s" namespace:', $describedNamespace), $options); @@ -202,7 +202,7 @@ protected function describeApplication(Application $application, array $options } foreach ($namespaces as $namespace) { - $namespace['commands'] = array_filter($namespace['commands'], fn ($name) => isset($commands[$name])); + $namespace['commands'] = array_filter($namespace['commands'], static fn ($name) => isset($commands[$name])); if (!$namespace['commands']) { continue; diff --git a/Helper/Dumper.php b/Helper/Dumper.php index a3b8e3952..316237a56 100644 --- a/Helper/Dumper.php +++ b/Helper/Dumper.php @@ -40,7 +40,7 @@ public function __construct(OutputInterface $output, ?CliDumper $dumper = null, return rtrim($dumper->dump(($this->cloner ??= new VarCloner())->cloneVar($var)->withRefHandles(false), true)); }; } else { - $this->handler = fn ($var): string => match (true) { + $this->handler = static fn ($var): string => match (true) { null === $var => 'null', true === $var => 'true', false === $var => 'false', diff --git a/Helper/ProgressBar.php b/Helper/ProgressBar.php index 8143acaff..4ab1c80ab 100644 --- a/Helper/ProgressBar.php +++ b/Helper/ProgressBar.php @@ -539,7 +539,7 @@ private function determineBestFormat(): string private static function initPlaceholderFormatters(): array { return [ - 'bar' => function (self $bar, OutputInterface $output) { + 'bar' => static function (self $bar, OutputInterface $output) { $completeBars = $bar->getBarOffset(); $display = str_repeat($bar->getBarCharacter(), $completeBars); if ($completeBars < $bar->getBarWidth()) { @@ -549,25 +549,25 @@ private static function initPlaceholderFormatters(): array return $display; }, - 'elapsed' => fn (self $bar) => Helper::formatTime(time() - $bar->getStartTime(), 2), - 'remaining' => function (self $bar) { + 'elapsed' => static fn (self $bar) => Helper::formatTime(time() - $bar->getStartTime(), 2), + 'remaining' => static function (self $bar) { if (!$bar->getMaxSteps()) { throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); } return Helper::formatTime($bar->getRemaining(), 2); }, - 'estimated' => function (self $bar) { + 'estimated' => static function (self $bar) { if (!$bar->getMaxSteps()) { throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); } return Helper::formatTime($bar->getEstimated(), 2); }, - 'memory' => fn (self $bar) => Helper::formatMemory(memory_get_usage(true)), - 'current' => fn (self $bar) => str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT), - 'max' => fn (self $bar) => $bar->getMaxSteps(), - 'percent' => fn (self $bar) => floor($bar->getProgressPercent() * 100), + 'memory' => static fn (self $bar) => Helper::formatMemory(memory_get_usage(true)), + 'current' => static fn (self $bar) => str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT), + 'max' => static fn (self $bar) => $bar->getMaxSteps(), + 'percent' => static fn (self $bar) => floor($bar->getProgressPercent() * 100), ]; } diff --git a/Helper/ProgressIndicator.php b/Helper/ProgressIndicator.php index 8c0475ed4..ed17bde3e 100644 --- a/Helper/ProgressIndicator.php +++ b/Helper/ProgressIndicator.php @@ -231,10 +231,10 @@ private function getCurrentTimeInMilliseconds(): float private static function initPlaceholderFormatters(): array { return [ - 'indicator' => fn (self $indicator) => $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)], - 'message' => fn (self $indicator) => $indicator->message, - 'elapsed' => fn (self $indicator) => Helper::formatTime(time() - $indicator->startTime, 2), - 'memory' => fn () => Helper::formatMemory(memory_get_usage(true)), + 'indicator' => static fn (self $indicator) => $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)], + 'message' => static fn (self $indicator) => $indicator->message, + 'elapsed' => static fn (self $indicator) => Helper::formatTime(time() - $indicator->startTime, 2), + 'memory' => static fn () => Helper::formatMemory(memory_get_usage(true)), ]; } } diff --git a/Helper/QuestionHelper.php b/Helper/QuestionHelper.php index 342a2a7e5..c1c84c041 100644 --- a/Helper/QuestionHelper.php +++ b/Helper/QuestionHelper.php @@ -323,7 +323,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu $matches = array_filter( $autocomplete($ret), - fn ($match) => '' === $ret || str_starts_with($match, $ret) + static fn ($match) => '' === $ret || str_starts_with($match, $ret) ); $numMatches = \count($matches); $ofs = -1; diff --git a/Input/Input.php b/Input/Input.php index d3a3c7fd2..3f4f32428 100644 --- a/Input/Input.php +++ b/Input/Input.php @@ -71,7 +71,7 @@ public function validate() $definition = $this->definition; $givenArguments = $this->arguments; - $missingArguments = array_filter(array_keys($definition->getArguments()), fn ($argument) => !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired()); + $missingArguments = array_filter(array_keys($definition->getArguments()), static fn ($argument) => !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired()); if (\count($missingArguments) > 0) { throw new RuntimeException(\sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments))); diff --git a/Question/ConfirmationQuestion.php b/Question/ConfirmationQuestion.php index 40eab2429..ea8d46e80 100644 --- a/Question/ConfirmationQuestion.php +++ b/Question/ConfirmationQuestion.php @@ -41,7 +41,7 @@ private function getDefaultNormalizer(): callable $default = $this->getDefault(); $regex = $this->trueAnswerRegex; - return function ($answer) use ($default, $regex) { + return static function ($answer) use ($default, $regex) { if (\is_bool($answer)) { return $answer; } diff --git a/SignalRegistry/SignalMap.php b/SignalRegistry/SignalMap.php index 2f9aa67c1..f696377f4 100644 --- a/SignalRegistry/SignalMap.php +++ b/SignalRegistry/SignalMap.php @@ -27,7 +27,7 @@ public static function getSignalName(int $signal): ?string if (!isset(self::$map)) { $r = new \ReflectionExtension('pcntl'); $c = $r->getConstants(); - $map = array_filter($c, fn ($k) => str_starts_with($k, 'SIG') && !str_starts_with($k, 'SIG_') && 'SIGBABY' !== $k, \ARRAY_FILTER_USE_KEY); + $map = array_filter($c, static fn ($k) => str_starts_with($k, 'SIG') && !str_starts_with($k, 'SIG_') && 'SIGBABY' !== $k, \ARRAY_FILTER_USE_KEY); self::$map = array_flip($map); } diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index 6f439d99a..65d49590f 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -177,7 +177,7 @@ public function testAllWithCommandLoader() $this->assertCount(1, $commands, '->all() takes a namespace as its first argument'); $application->setCommandLoader(new FactoryCommandLoader([ - 'foo:bar1' => fn () => new \Foo1Command(), + 'foo:bar1' => static fn () => new \Foo1Command(), ])); $commands = $application->all('foo'); $this->assertCount(2, $commands, '->all() takes a namespace as its first argument'); @@ -194,7 +194,7 @@ public function testRegister() public function testRegisterAmbiguous() { - $code = function (InputInterface $input, OutputInterface $output) { + $code = static function (InputInterface $input, OutputInterface $output) { $output->writeln('It works!'); }; @@ -268,7 +268,7 @@ public function testHasGetWithCommandLoader() $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); $application->setCommandLoader(new FactoryCommandLoader([ - 'foo:bar1' => fn () => new \Foo1Command(), + 'foo:bar1' => static fn () => new \Foo1Command(), ])); $this->assertTrue($application->has('afoobar'), '->has() returns true if an instance is registered for an alias even with command loader'); @@ -432,7 +432,7 @@ public function testFindWithCommandLoader() { $application = new Application(); $application->setCommandLoader(new FactoryCommandLoader([ - 'foo:bar' => $f = fn () => new \FooCommand(), + 'foo:bar' => $f = static fn () => new \FooCommand(), ])); $this->assertInstanceOf(\FooCommand::class, $application->find('foo:bar'), '->find() returns a command if its name exists'); @@ -832,7 +832,7 @@ public function testSetCatchErrors(bool $catchExceptions) $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions($catchExceptions); - $application->add((new Command('boom'))->setCode(fn () => throw new \Error('This is an error.'))); + $application->add((new Command('boom'))->setCode(static fn () => throw new \Error('This is an error.'))); putenv('COLUMNS=120'); $tester = new ApplicationTester($application); @@ -906,7 +906,7 @@ public function testRenderExceptionWithDoubleWidthCharacters() $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=120'); - $application->register('foo')->setCode(function () { + $application->register('foo')->setCode(static function () { throw new \Exception('エラーメッセージ'); }); $tester = new ApplicationTester($application); @@ -920,7 +920,7 @@ public function testRenderExceptionWithDoubleWidthCharacters() $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=32'); - $application->register('foo')->setCode(function () { + $application->register('foo')->setCode(static function () { throw new \Exception('コマンドの実行中にエラーが発生しました。'); }); $tester = new ApplicationTester($application); @@ -934,7 +934,7 @@ public function testRenderExceptionEscapesLines() $application = new Application(); $application->setAutoExit(false); putenv('COLUMNS=22'); - $application->register('foo')->setCode(function () { + $application->register('foo')->setCode(static function () { throw new \Exception('dont break here !'); }); $tester = new ApplicationTester($application); @@ -953,7 +953,7 @@ public function getTerminalWidth(): int } }; $application->setAutoExit(false); - $application->register('foo')->setCode(function () { + $application->register('foo')->setCode(static function () { throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n"); }); $tester = new ApplicationTester($application); @@ -969,7 +969,7 @@ public function testRenderAnonymousException() { $application = new Application(); $application->setAutoExit(false); - $application->register('foo')->setCode(function () { + $application->register('foo')->setCode(static function () { throw new class('') extends \InvalidArgumentException {}; }); $tester = new ApplicationTester($application); @@ -979,7 +979,7 @@ public function testRenderAnonymousException() $application = new Application(); $application->setAutoExit(false); - $application->register('foo')->setCode(function () { + $application->register('foo')->setCode(static function () { throw new \InvalidArgumentException(\sprintf('Dummy type "%s" is invalid.', (new class {})::class)); }); $tester = new ApplicationTester($application); @@ -995,7 +995,7 @@ public function testRenderExceptionStackTraceContainsRootException() { $application = new Application(); $application->setAutoExit(false); - $application->register('foo')->setCode(function () { + $application->register('foo')->setCode(static function () { throw new class('') extends \InvalidArgumentException {}; }); $tester = new ApplicationTester($application); @@ -1005,7 +1005,7 @@ public function testRenderExceptionStackTraceContainsRootException() $application = new Application(); $application->setAutoExit(false); - $application->register('foo')->setCode(function () { + $application->register('foo')->setCode(static function () { throw new \InvalidArgumentException(\sprintf('Dummy type "%s" is invalid.', (new class {})::class)); }); $tester = new ApplicationTester($application); @@ -1020,7 +1020,7 @@ public function testRenderExceptionEscapesLinesOfSynopsis() $application->setAutoExit(false); $application ->register('foo') - ->setCode(function () { + ->setCode(static function () { throw new \Exception('some exception'); }) ->addArgument('info') @@ -1192,7 +1192,7 @@ public function testRunDispatchesIntegerExitCode() // We can assume here that some other test asserts that the event is dispatched at all $dispatcher = new EventDispatcher(); - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) { + $dispatcher->addListener('console.terminate', static function (ConsoleTerminateEvent $event) use (&$passedRightValue) { $passedRightValue = (4 === $event->getExitCode()); }); @@ -1200,7 +1200,7 @@ public function testRunDispatchesIntegerExitCode() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('test')->setCode(static function (InputInterface $input, OutputInterface $output) { throw new \Exception('', 4); }); @@ -1231,7 +1231,7 @@ public function testRunDispatchesExitCodeOneForExceptionCodeZero() // We can assume here that some other test asserts that the event is dispatched at all $dispatcher = new EventDispatcher(); - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) { + $dispatcher->addListener('console.terminate', static function (ConsoleTerminateEvent $event) use (&$passedRightValue) { $passedRightValue = (1 === $event->getExitCode()); }); @@ -1239,7 +1239,7 @@ public function testRunDispatchesExitCodeOneForExceptionCodeZero() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('test')->setCode(static function (InputInterface $input, OutputInterface $output) { throw new \Exception(); }); @@ -1282,7 +1282,7 @@ public function testAddingOptionWithDuplicateShortcut() ->register('foo') ->setAliases(['f']) ->setDefinition([new InputOption('survey', 'e', InputOption::VALUE_REQUIRED, 'My option with a shortcut.')]) - ->setCode(function (InputInterface $input, OutputInterface $output) {}) + ->setCode(static function (InputInterface $input, OutputInterface $output) {}) ; $input = new ArrayInput(['command' => 'foo']); @@ -1305,7 +1305,7 @@ public function testAddingAlreadySetDefinitionElementData($def) $application ->register('foo') ->setDefinition([$def]) - ->setCode(function (InputInterface $input, OutputInterface $output) {}) + ->setCode(static function (InputInterface $input, OutputInterface $output) {}) ; $input = new ArrayInput(['command' => 'foo']); @@ -1442,7 +1442,7 @@ public function testRunWithDispatcher() $application->setAutoExit(false); $application->setDispatcher($this->getDispatcher()); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); @@ -1458,7 +1458,7 @@ public function testRunWithExceptionAndDispatcher() $application->setAutoExit(false); $application->setCatchExceptions(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { throw new \RuntimeException('foo'); }); @@ -1476,7 +1476,7 @@ public function testRunDispatchesAllEventsWithException() $application->setDispatcher($this->getDispatcher()); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); throw new \RuntimeException('foo'); @@ -1490,7 +1490,7 @@ public function testRunDispatchesAllEventsWithException() public function testRunDispatchesAllEventsWithExceptionInListener() { $dispatcher = $this->getDispatcher(); - $dispatcher->addListener('console.command', function () { + $dispatcher->addListener('console.command', static function () { throw new \RuntimeException('foo'); }); @@ -1498,7 +1498,7 @@ public function testRunDispatchesAllEventsWithExceptionInListener() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); @@ -1513,7 +1513,7 @@ public function testRunWithError() $application->setAutoExit(false); $application->setCatchExceptions(false); - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('dym')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('dym.'); throw new \Error('dymerr'); @@ -1552,13 +1552,13 @@ public function testRunWithFindError() public function testRunAllowsErrorListenersToSilenceTheException() { $dispatcher = $this->getDispatcher(); - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { + $dispatcher->addListener('console.error', static function (ConsoleErrorEvent $event) { $event->getOutput()->write('silenced.'); $event->setExitCode(0); }); - $dispatcher->addListener('console.command', function () { + $dispatcher->addListener('console.command', static function () { throw new \RuntimeException('foo'); }); @@ -1566,7 +1566,7 @@ public function testRunAllowsErrorListenersToSilenceTheException() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); @@ -1602,7 +1602,7 @@ public function testErrorIsRethrownIfNotHandledByConsoleErrorEvent() $application->setCatchExceptions(false); $application->setDispatcher(new EventDispatcher()); - $application->register('dym')->setCode(function () { + $application->register('dym')->setCode(static function () { throw new \Error('Something went wrong.'); }); @@ -1623,7 +1623,7 @@ public function testRunWithErrorAndDispatcher() $application->setAutoExit(false); $application->setCatchExceptions(false); - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('dym')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('dym.'); throw new \Error('dymerr'); @@ -1644,7 +1644,7 @@ public function testRunDispatchesAllEventsWithError() $application->setDispatcher($this->getDispatcher()); $application->setAutoExit(false); - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('dym')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('dym.'); throw new \Error('dymerr'); @@ -1661,7 +1661,7 @@ public function testRunWithErrorFailingStatusCode() $application->setDispatcher($this->getDispatcher()); $application->setAutoExit(false); - $application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('dus')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('dus.'); throw new \Error('duserr'); @@ -1678,7 +1678,7 @@ public function testRunWithDispatcherSkippingCommand() $application->setDispatcher($this->getDispatcher(true)); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); @@ -1694,7 +1694,7 @@ public function testRunWithDispatcherAccessingInputOptions() $quietValue = null; $dispatcher = $this->getDispatcher(); - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { + $dispatcher->addListener('console.command', static function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { $input = $event->getInput(); $noInteractionValue = $input->getOption('no-interaction'); @@ -1705,7 +1705,7 @@ public function testRunWithDispatcherAccessingInputOptions() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); @@ -1721,7 +1721,7 @@ public function testRunWithDispatcherAddingInputOptions() $extraValue = null; $dispatcher = $this->getDispatcher(); - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$extraValue) { + $dispatcher->addListener('console.command', static function (ConsoleCommandEvent $event) use (&$extraValue) { $definition = $event->getCommand()->getDefinition(); $input = $event->getInput(); @@ -1735,7 +1735,7 @@ public function testRunWithDispatcherAddingInputOptions() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); @@ -1833,7 +1833,7 @@ public function testRunLazyCommandService() public function testGetDisabledLazyCommand() { $application = new Application(); - $application->setCommandLoader(new FactoryCommandLoader(['disabled' => fn () => new DisabledCommand()])); + $application->setCommandLoader(new FactoryCommandLoader(['disabled' => static fn () => new DisabledCommand()])); $this->expectException(CommandNotFoundException::class); @@ -1843,14 +1843,14 @@ public function testGetDisabledLazyCommand() public function testHasReturnsFalseForDisabledLazyCommand() { $application = new Application(); - $application->setCommandLoader(new FactoryCommandLoader(['disabled' => fn () => new DisabledCommand()])); + $application->setCommandLoader(new FactoryCommandLoader(['disabled' => static fn () => new DisabledCommand()])); $this->assertFalse($application->has('disabled')); } public function testAllExcludesDisabledLazyCommand() { $application = new Application(); - $application->setCommandLoader(new FactoryCommandLoader(['disabled' => fn () => new DisabledCommand()])); + $application->setCommandLoader(new FactoryCommandLoader(['disabled' => static fn () => new DisabledCommand()])); $this->assertArrayNotHasKey('disabled', $application->all()); } @@ -1862,15 +1862,15 @@ public function testFindAlternativesDoesNotLoadSameNamespaceCommandsOnExactMatch $loaded = []; $application->setCommandLoader(new FactoryCommandLoader([ - 'foo:bar' => function () use (&$loaded) { + 'foo:bar' => static function () use (&$loaded) { $loaded['foo:bar'] = true; - return (new Command('foo:bar'))->setCode(function () {}); + return (new Command('foo:bar'))->setCode(static function () {}); }, - 'foo' => function () use (&$loaded) { + 'foo' => static function () use (&$loaded) { $loaded['foo'] = true; - return (new Command('foo'))->setCode(function () {}); + return (new Command('foo'))->setCode(static function () {}); }, ])); @@ -1882,21 +1882,21 @@ public function testFindAlternativesDoesNotLoadSameNamespaceCommandsOnExactMatch protected function getDispatcher($skipCommand = false) { $dispatcher = new EventDispatcher(); - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) { + $dispatcher->addListener('console.command', static function (ConsoleCommandEvent $event) use ($skipCommand) { $event->getOutput()->write('before.'); if ($skipCommand) { $event->disableCommand(); } }); - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) { + $dispatcher->addListener('console.terminate', static function (ConsoleTerminateEvent $event) use ($skipCommand) { $event->getOutput()->writeln('after.'); if (!$skipCommand) { $event->setExitCode(ConsoleCommandEvent::RETURN_CODE_DISABLED); } }); - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { + $dispatcher->addListener('console.error', static function (ConsoleErrorEvent $event) { $event->getOutput()->write('error.'); $event->setError(new \LogicException('error.', $event->getExitCode(), $event->getError())); @@ -1911,7 +1911,7 @@ public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEn $application->setAutoExit(false); $application->setDispatcher(new EventDispatcher()); - $application->register('dym')->setCode(function () { + $application->register('dym')->setCode(static function () { throw new \Error('Something went wrong.'); }); @@ -1928,11 +1928,11 @@ public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEn public function testThrowingErrorListener() { $dispatcher = $this->getDispatcher(); - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { + $dispatcher->addListener('console.error', static function (ConsoleErrorEvent $event) { throw new \RuntimeException('foo'); }); - $dispatcher->addListener('console.command', function () { + $dispatcher->addListener('console.command', static function () { throw new \RuntimeException('bar'); }); @@ -1941,7 +1941,7 @@ public function testThrowingErrorListener() $application->setAutoExit(false); $application->setCatchExceptions(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(static function (InputInterface $input, OutputInterface $output) { $output->write('foo.'); }); @@ -1977,7 +1977,7 @@ public function testSignalListenerNotCalledByDefault() $dispatcherCalled = false; $dispatcher = new EventDispatcher(); - $dispatcher->addListener('console.signal', function () use (&$dispatcherCalled) { + $dispatcher->addListener('console.signal', static function () use (&$dispatcherCalled) { $dispatcherCalled = true; }); @@ -1997,7 +1997,7 @@ public function testSignalListener() $dispatcherCalled = false; $dispatcher = new EventDispatcher(); - $dispatcher->addListener('console.signal', function (ConsoleSignalEvent $e) use (&$dispatcherCalled) { + $dispatcher->addListener('console.signal', static function (ConsoleSignalEvent $e) use (&$dispatcherCalled) { $e->abortExit(); $dispatcherCalled = true; }); @@ -2095,7 +2095,7 @@ public function testSetSignalsToDispatchEvent() // on SIGUSR1, we need to register a blank handler to avoid the process // being stopped. $blankHandlerSignaled = false; - pcntl_signal(\SIGUSR1, function () use (&$blankHandlerSignaled) { + pcntl_signal(\SIGUSR1, static function () use (&$blankHandlerSignaled) { $blankHandlerSignaled = true; }); @@ -2189,7 +2189,7 @@ public function testSignalableWithEventCommandDoesNotInterruptedOnTermSignals() $terminateEventDispatched = false; $dispatcher = new EventDispatcher(); $dispatcher->addSubscriber($command); - $dispatcher->addListener('console.terminate', function () use (&$terminateEventDispatched) { + $dispatcher->addListener('console.terminate', static function () use (&$terminateEventDispatched) { $terminateEventDispatched = true; }); $application = new Application(); @@ -2516,7 +2516,7 @@ private function createSignalableApplication(Command $command, ?EventDispatcherI if ($dispatcher) { $application->setDispatcher($dispatcher); } - $application->add(new LazyCommand('signal', [], '', false, fn () => $command, true)); + $application->add(new LazyCommand('signal', [], '', false, static fn () => $command, true)); return $application; } diff --git a/Tests/Command/CommandTest.php b/Tests/Command/CommandTest.php index 58fbfcf79..3942e3680 100644 --- a/Tests/Command/CommandTest.php +++ b/Tests/Command/CommandTest.php @@ -350,7 +350,7 @@ public function testRunWithProcessTitle() public function testSetCode() { $command = new \TestCommand(); - $ret = $command->setCode(function (InputInterface $input, OutputInterface $output) { + $ret = $command->setCode(static function (InputInterface $input, OutputInterface $output) { $output->writeln('from the code...'); }); $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); diff --git a/Tests/CommandLoader/ContainerCommandLoaderTest.php b/Tests/CommandLoader/ContainerCommandLoaderTest.php index f2049ef5c..5e56228db 100644 --- a/Tests/CommandLoader/ContainerCommandLoaderTest.php +++ b/Tests/CommandLoader/ContainerCommandLoaderTest.php @@ -22,8 +22,8 @@ class ContainerCommandLoaderTest extends TestCase public function testHas() { $loader = new ContainerCommandLoader(new ServiceLocator([ - 'foo-service' => fn () => new Command('foo'), - 'bar-service' => fn () => new Command('bar'), + 'foo-service' => static fn () => new Command('foo'), + 'bar-service' => static fn () => new Command('bar'), ]), ['foo' => 'foo-service', 'bar' => 'bar-service']); $this->assertTrue($loader->has('foo')); @@ -34,8 +34,8 @@ public function testHas() public function testGet() { $loader = new ContainerCommandLoader(new ServiceLocator([ - 'foo-service' => fn () => new Command('foo'), - 'bar-service' => fn () => new Command('bar'), + 'foo-service' => static fn () => new Command('foo'), + 'bar-service' => static fn () => new Command('bar'), ]), ['foo' => 'foo-service', 'bar' => 'bar-service']); $this->assertInstanceOf(Command::class, $loader->get('foo')); @@ -51,8 +51,8 @@ public function testGetUnknownCommandThrows() public function testGetCommandNames() { $loader = new ContainerCommandLoader(new ServiceLocator([ - 'foo-service' => fn () => new Command('foo'), - 'bar-service' => fn () => new Command('bar'), + 'foo-service' => static fn () => new Command('foo'), + 'bar-service' => static fn () => new Command('bar'), ]), ['foo' => 'foo-service', 'bar' => 'bar-service']); $this->assertSame(['foo', 'bar'], $loader->getNames()); diff --git a/Tests/CommandLoader/FactoryCommandLoaderTest.php b/Tests/CommandLoader/FactoryCommandLoaderTest.php index 148806413..c12e2d132 100644 --- a/Tests/CommandLoader/FactoryCommandLoaderTest.php +++ b/Tests/CommandLoader/FactoryCommandLoaderTest.php @@ -21,8 +21,8 @@ class FactoryCommandLoaderTest extends TestCase public function testHas() { $loader = new FactoryCommandLoader([ - 'foo' => fn () => new Command('foo'), - 'bar' => fn () => new Command('bar'), + 'foo' => static fn () => new Command('foo'), + 'bar' => static fn () => new Command('bar'), ]); $this->assertTrue($loader->has('foo')); @@ -33,8 +33,8 @@ public function testHas() public function testGet() { $loader = new FactoryCommandLoader([ - 'foo' => fn () => new Command('foo'), - 'bar' => fn () => new Command('bar'), + 'foo' => static fn () => new Command('foo'), + 'bar' => static fn () => new Command('bar'), ]); $this->assertInstanceOf(Command::class, $loader->get('foo')); @@ -50,8 +50,8 @@ public function testGetUnknownCommandThrows() public function testGetCommandNames() { $loader = new FactoryCommandLoader([ - 'foo' => fn () => new Command('foo'), - 'bar' => fn () => new Command('bar'), + 'foo' => static fn () => new Command('foo'), + 'bar' => static fn () => new Command('bar'), ]); $this->assertSame(['foo', 'bar'], $loader->getNames()); diff --git a/Tests/Helper/ProcessHelperTest.php b/Tests/Helper/ProcessHelperTest.php index ac7363fba..8c271a159 100644 --- a/Tests/Helper/ProcessHelperTest.php +++ b/Tests/Helper/ProcessHelperTest.php @@ -91,7 +91,7 @@ public function testPassedCallbackIsExecuted() $output = $this->getOutputStream(StreamOutput::VERBOSITY_NORMAL); $executed = false; - $callback = function () use (&$executed) { $executed = true; }; + $callback = static function () use (&$executed) { $executed = true; }; $helper->run($output, ['php', '-r', 'echo 42;'], null, $callback); $this->assertTrue($executed); diff --git a/Tests/Helper/ProgressBarTest.php b/Tests/Helper/ProgressBarTest.php index af7cf2ef5..f6d6e900f 100644 --- a/Tests/Helper/ProgressBarTest.php +++ b/Tests/Helper/ProgressBarTest.php @@ -949,7 +949,7 @@ public function testWithSmallScreen() public function testAddingPlaceholderFormatter() { - ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', fn (ProgressBar $bar) => $bar->getMaxSteps() - $bar->getProgress()); + ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', static fn (ProgressBar $bar) => $bar->getMaxSteps() - $bar->getProgress()); $bar = new ProgressBar($output = $this->getOutputStream(), 3, 0); $bar->setFormat(' %remaining_steps% [%bar%]'); @@ -970,7 +970,7 @@ public function testAddingInstancePlaceholderFormatter() { $bar = new ProgressBar($output = $this->getOutputStream(), 3, 0); $bar->setFormat(' %countdown% [%bar%]'); - $bar->setPlaceholderFormatter('countdown', $function = fn (ProgressBar $bar) => $bar->getMaxSteps() - $bar->getProgress()); + $bar->setPlaceholderFormatter('countdown', $function = static fn (ProgressBar $bar) => $bar->getMaxSteps() - $bar->getProgress()); $this->assertSame($function, $bar->getPlaceholderFormatter('countdown')); @@ -1014,7 +1014,7 @@ public function testAnsiColorsAndEmojis() putenv('COLUMNS=156'); $bar = new ProgressBar($output = $this->getOutputStream(), 15, 0); - ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) { + ProgressBar::setPlaceholderFormatterDefinition('memory', static function (ProgressBar $bar) { static $i = 0; $mem = 100000 * $i; $colors = $i++ ? '41;37' : '44;37'; @@ -1162,7 +1162,7 @@ public function testIterateUncountable() { $bar = new ProgressBar($output = $this->getOutputStream(), 0, 0); - $this->assertEquals([1, 2], iterator_to_array($bar->iterate((function () { + $this->assertEquals([1, 2], iterator_to_array($bar->iterate((static function () { yield 1; yield 2; })()))); diff --git a/Tests/Helper/QuestionHelperTest.php b/Tests/Helper/QuestionHelperTest.php index dc6c47fc2..7407df8b8 100644 --- a/Tests/Helper/QuestionHelperTest.php +++ b/Tests/Helper/QuestionHelperTest.php @@ -281,14 +281,14 @@ public function testAskWithAutocompleteCallback() // // No effort is made to avoid irrelevant suggestions, as this is handled // by the autocomplete function. - $callback = function ($input) { + $callback = static function ($input) { $knownWords = ['Carrot', 'Creme', 'Curry', 'Parsnip', 'Pie', 'Potato', 'Tart']; $inputWords = explode(' ', $input); array_pop($inputWords); $suggestionBase = $inputWords ? implode(' ', $inputWords).' ' : ''; return array_map( - fn ($word) => $suggestionBase.$word.' ', + static fn ($word) => $suggestionBase.$word.' ', $knownWords ); }; @@ -584,7 +584,7 @@ public function testAskAndValidate() $dialog->setHelperSet($helperSet); $error = 'This is not a color!'; - $validator = function ($color) use ($error) { + $validator = static function ($color) use ($error) { if (!\in_array($color, ['white', 'black'])) { throw new \InvalidArgumentException($error); } @@ -779,7 +779,7 @@ public function testAskThrowsExceptionOnMissingInputWithValidator() $dialog = new QuestionHelper(); $question = new Question('What\'s your name?'); - $question->setValidator(function ($value) { + $question->setValidator(static function ($value) { if (!$value) { throw new \Exception('A value is required.'); } @@ -796,7 +796,7 @@ public function testValidatorExceptionPropagatesOnEmptyInput() $dialog = new QuestionHelper(); $question = new Question('What\'s your name?'); - $question->setValidator(function ($value) { + $question->setValidator(static function ($value) { if ('' === $value || null === $value) { throw new \InvalidArgumentException('A value is required.'); } @@ -817,9 +817,9 @@ public function testQuestionValidatorRepeatsThePrompt() $application = new Application(); $application->setAutoExit(false); $application->register('question') - ->setCode(function ($input, $output) use (&$tries) { + ->setCode(static function ($input, $output) use (&$tries) { $question = new Question('This is a promptable question'); - $question->setValidator(function ($value) use (&$tries) { + $question->setValidator(static function ($value) use (&$tries) { ++$tries; if (!$value) { throw new \Exception(); diff --git a/Tests/Helper/SymfonyQuestionHelperTest.php b/Tests/Helper/SymfonyQuestionHelperTest.php index 99460a849..8f7255020 100644 --- a/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/Tests/Helper/SymfonyQuestionHelperTest.php @@ -101,7 +101,7 @@ public function testAskReturnsNullIfValidatorAllowsIt() { $questionHelper = new SymfonyQuestionHelper(); $question = new Question('What is your favorite superhero?'); - $question->setValidator(fn ($value) => $value); + $question->setValidator(static fn ($value) => $value); $input = $this->createStreamableInputInterfaceMock($this->getInputStream("\n")); $this->assertNull($questionHelper->ask($input, $this->createOutputInterface(), $question)); } diff --git a/Tests/Input/InputArgumentTest.php b/Tests/Input/InputArgumentTest.php index 05447426c..59db3ee1a 100644 --- a/Tests/Input/InputArgumentTest.php +++ b/Tests/Input/InputArgumentTest.php @@ -121,22 +121,22 @@ public function testCompleteArray() $this->assertTrue($argument->hasCompletion()); $suggestions = new CompletionSuggestions(); $argument->complete(new CompletionInput(), $suggestions); - $this->assertSame($values, array_map(fn (Suggestion $suggestion) => $suggestion->getValue(), $suggestions->getValueSuggestions())); + $this->assertSame($values, array_map(static fn (Suggestion $suggestion) => $suggestion->getValue(), $suggestions->getValueSuggestions())); } public function testCompleteClosure() { $values = ['foo', 'bar']; - $argument = new InputArgument('foo', null, '', null, fn (CompletionInput $input): array => $values); + $argument = new InputArgument('foo', null, '', null, static fn (CompletionInput $input): array => $values); $this->assertTrue($argument->hasCompletion()); $suggestions = new CompletionSuggestions(); $argument->complete(new CompletionInput(), $suggestions); - $this->assertSame($values, array_map(fn (Suggestion $suggestion) => $suggestion->getValue(), $suggestions->getValueSuggestions())); + $this->assertSame($values, array_map(static fn (Suggestion $suggestion) => $suggestion->getValue(), $suggestions->getValueSuggestions())); } public function testCompleteClosureReturnIncorrectType() { - $argument = new InputArgument('foo', InputArgument::OPTIONAL, '', null, fn (CompletionInput $input) => 'invalid'); + $argument = new InputArgument('foo', InputArgument::OPTIONAL, '', null, static fn (CompletionInput $input) => 'invalid'); $this->expectException(LogicException::class); $this->expectExceptionMessage('Closure for argument "foo" must return an array. Got "string".'); diff --git a/Tests/Input/InputOptionTest.php b/Tests/Input/InputOptionTest.php index 7e3fb16da..6c6c3615c 100644 --- a/Tests/Input/InputOptionTest.php +++ b/Tests/Input/InputOptionTest.php @@ -234,22 +234,22 @@ public function testCompleteArray() $this->assertTrue($option->hasCompletion()); $suggestions = new CompletionSuggestions(); $option->complete(new CompletionInput(), $suggestions); - $this->assertSame($values, array_map(fn (Suggestion $suggestion) => $suggestion->getValue(), $suggestions->getValueSuggestions())); + $this->assertSame($values, array_map(static fn (Suggestion $suggestion) => $suggestion->getValue(), $suggestions->getValueSuggestions())); } public function testCompleteClosure() { $values = ['foo', 'bar']; - $option = new InputOption('foo', null, InputOption::VALUE_OPTIONAL, '', null, fn (CompletionInput $input): array => $values); + $option = new InputOption('foo', null, InputOption::VALUE_OPTIONAL, '', null, static fn (CompletionInput $input): array => $values); $this->assertTrue($option->hasCompletion()); $suggestions = new CompletionSuggestions(); $option->complete(new CompletionInput(), $suggestions); - $this->assertSame($values, array_map(fn (Suggestion $suggestion) => $suggestion->getValue(), $suggestions->getValueSuggestions())); + $this->assertSame($values, array_map(static fn (Suggestion $suggestion) => $suggestion->getValue(), $suggestions->getValueSuggestions())); } public function testCompleteClosureReturnIncorrectType() { - $option = new InputOption('foo', null, InputOption::VALUE_OPTIONAL, '', null, fn (CompletionInput $input) => 'invalid'); + $option = new InputOption('foo', null, InputOption::VALUE_OPTIONAL, '', null, static fn (CompletionInput $input) => 'invalid'); $this->expectException(LogicException::class); $this->expectExceptionMessage('Closure for option "foo" must return an array. Got "string".'); diff --git a/Tests/Question/QuestionTest.php b/Tests/Question/QuestionTest.php index 0bc6f75db..f26292b18 100644 --- a/Tests/Question/QuestionTest.php +++ b/Tests/Question/QuestionTest.php @@ -62,7 +62,7 @@ public function testIsHiddenDefault() public function testSetHiddenWithAutocompleterCallback() { $this->question->setAutocompleterCallback( - fn (string $input): array => [] + static fn (string $input): array => [] ); $this->expectException(\LogicException::class); @@ -76,7 +76,7 @@ public function testSetHiddenWithAutocompleterCallback() public function testSetHiddenWithNoAutocompleterCallback() { $this->question->setAutocompleterCallback( - fn (string $input): array => [] + static fn (string $input): array => [] ); $this->question->setAutocompleterCallback(null); @@ -187,7 +187,7 @@ public function testGetAutocompleterValuesDefault() public function testGetSetAutocompleterCallback() { - $callback = fn (string $input): array => []; + $callback = static fn (string $input): array => []; $this->question->setAutocompleterCallback($callback); self::assertSame($callback, $this->question->getAutocompleterCallback()); @@ -208,7 +208,7 @@ public function testSetAutocompleterCallbackWhenHidden() ); $this->question->setAutocompleterCallback( - fn (string $input): array => [] + static fn (string $input): array => [] ); } @@ -220,7 +220,7 @@ public function testSetAutocompleterCallbackWhenNotHidden() $exception = null; try { $this->question->setAutocompleterCallback( - fn (string $input): array => [] + static fn (string $input): array => [] ); } catch (\Exception $exception) { // Do nothing @@ -232,7 +232,7 @@ public function testSetAutocompleterCallbackWhenNotHidden() public static function providerGetSetValidator() { return [ - [fn ($input) => $input], + [static fn ($input) => $input], [null], ]; } @@ -288,7 +288,7 @@ public function testGetMaxAttemptsDefault() public function testGetSetNormalizer() { - $normalizer = fn ($input) => $input; + $normalizer = static fn ($input) => $input; $this->question->setNormalizer($normalizer); self::assertSame($normalizer, $this->question->getNormalizer()); } diff --git a/Tests/SignalRegistry/SignalRegistryTest.php b/Tests/SignalRegistry/SignalRegistryTest.php index 77b7e28e7..0ab529c80 100644 --- a/Tests/SignalRegistry/SignalRegistryTest.php +++ b/Tests/SignalRegistry/SignalRegistryTest.php @@ -34,7 +34,7 @@ public function testOneCallbackForASignalSignalIsHandled() $signalRegistry = new SignalRegistry(); $isHandled = false; - $signalRegistry->register(\SIGUSR1, function () use (&$isHandled) { + $signalRegistry->register(\SIGUSR1, static function () use (&$isHandled) { $isHandled = true; }); @@ -48,12 +48,12 @@ public function testTwoCallbacksForASignalBothCallbacksAreCalled() $signalRegistry = new SignalRegistry(); $isHandled1 = false; - $signalRegistry->register(\SIGUSR1, function () use (&$isHandled1) { + $signalRegistry->register(\SIGUSR1, static function () use (&$isHandled1) { $isHandled1 = true; }); $isHandled2 = false; - $signalRegistry->register(\SIGUSR1, function () use (&$isHandled2) { + $signalRegistry->register(\SIGUSR1, static function () use (&$isHandled2) { $isHandled2 = true; }); @@ -70,7 +70,7 @@ public function testTwoSignalsSignalsAreHandled() $isHandled1 = false; $isHandled2 = false; - $signalRegistry->register(\SIGUSR1, function () use (&$isHandled1) { + $signalRegistry->register(\SIGUSR1, static function () use (&$isHandled1) { $isHandled1 = true; }); @@ -79,7 +79,7 @@ public function testTwoSignalsSignalsAreHandled() $this->assertTrue($isHandled1); $this->assertFalse($isHandled2); - $signalRegistry->register(\SIGUSR2, function () use (&$isHandled2) { + $signalRegistry->register(\SIGUSR2, static function () use (&$isHandled2) { $isHandled2 = true; }); @@ -93,12 +93,12 @@ public function testTwoCallbacksForASignalPreviousAndRegisteredCallbacksWereCall $signalRegistry = new SignalRegistry(); $isHandled1 = false; - pcntl_signal(\SIGUSR1, function () use (&$isHandled1) { + pcntl_signal(\SIGUSR1, static function () use (&$isHandled1) { $isHandled1 = true; }); $isHandled2 = false; - $signalRegistry->register(\SIGUSR1, function () use (&$isHandled2) { + $signalRegistry->register(\SIGUSR1, static function () use (&$isHandled2) { $isHandled2 = true; }); @@ -113,14 +113,14 @@ public function testTwoCallbacksForASignalPreviousCallbackFromAnotherRegistry() $signalRegistry1 = new SignalRegistry(); $isHandled1 = false; - $signalRegistry1->register(\SIGUSR1, function () use (&$isHandled1) { + $signalRegistry1->register(\SIGUSR1, static function () use (&$isHandled1) { $isHandled1 = true; }); $signalRegistry2 = new SignalRegistry(); $isHandled2 = false; - $signalRegistry2->register(\SIGUSR1, function () use (&$isHandled2) { + $signalRegistry2->register(\SIGUSR1, static function () use (&$isHandled2) { $isHandled2 = true; }); diff --git a/Tests/Tester/ApplicationTesterTest.php b/Tests/Tester/ApplicationTesterTest.php index a4d14c41a..686331732 100644 --- a/Tests/Tester/ApplicationTesterTest.php +++ b/Tests/Tester/ApplicationTesterTest.php @@ -29,7 +29,7 @@ protected function setUp(): void $this->application->setAutoExit(false); $this->application->register('foo') ->addArgument('foo') - ->setCode(function ($input, $output) { + ->setCode(static function ($input, $output) { $output->writeln('foo'); }) ; @@ -65,7 +65,7 @@ public function testSetInputs() { $application = new Application(); $application->setAutoExit(false); - $application->register('foo')->setCode(function ($input, $output) { + $application->register('foo')->setCode(static function ($input, $output) { $helper = new QuestionHelper(); $helper->ask($input, $output, new Question('Q1')); $helper->ask($input, $output, new Question('Q2')); @@ -133,7 +133,7 @@ public function testErrorOutput() $application->setAutoExit(false); $application->register('foo') ->addArgument('foo') - ->setCode(function ($input, $output) { + ->setCode(static function ($input, $output) { $output->getErrorOutput()->write('foo'); }) ; diff --git a/Tests/Tester/CommandTesterTest.php b/Tests/Tester/CommandTesterTest.php index 799618a1e..b5000c30d 100644 --- a/Tests/Tester/CommandTesterTest.php +++ b/Tests/Tester/CommandTesterTest.php @@ -34,7 +34,7 @@ protected function setUp(): void $this->command = new Command('foo'); $this->command->addArgument('command'); $this->command->addArgument('foo'); - $this->command->setCode(function ($input, $output) { $output->writeln('foo'); }); + $this->command->setCode(static function ($input, $output) { $output->writeln('foo'); }); $this->tester = new CommandTester($this->command); $this->tester->execute(['foo' => 'bar'], ['interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]); @@ -94,7 +94,7 @@ public function testCommandFromApplication() $application->setAutoExit(false); $command = new Command('foo'); - $command->setCode(function ($input, $output) { $output->writeln('foo'); }); + $command->setCode(static function ($input, $output) { $output->writeln('foo'); }); $application->add($command); @@ -114,7 +114,7 @@ public function testCommandWithInputs() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function ($input, $output) use ($questions, $command) { + $command->setCode(static function ($input, $output) use ($questions, $command) { $helper = $command->getHelper('question'); $helper->ask($input, $output, new Question($questions[0])); $helper->ask($input, $output, new Question($questions[1])); @@ -135,7 +135,7 @@ public function testCommandWithMultilineInputs() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function (InputInterface $input, OutputInterface $output) use ($question, $command): int { + $command->setCode(static function (InputInterface $input, OutputInterface $output) use ($question, $command): int { $output->write($command->getHelper('question')->ask($input, $output, (new Question($question))->setMultiline(true))); $output->write(stream_get_contents($input->getStream())); @@ -165,7 +165,7 @@ public function testCommandWithDefaultInputs() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function ($input, $output) use ($questions, $command) { + $command->setCode(static function ($input, $output) use ($questions, $command) { $helper = $command->getHelper('question'); $helper->ask($input, $output, new Question($questions[0], 'Bobby')); $helper->ask($input, $output, new Question($questions[1], 'Fine')); @@ -190,7 +190,7 @@ public function testCommandWithWrongInputsNumber() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function ($input, $output) use ($questions, $command) { + $command->setCode(static function ($input, $output) use ($questions, $command) { $helper = $command->getHelper('question'); $helper->ask($input, $output, new ChoiceQuestion('choice', ['a', 'b'])); $helper->ask($input, $output, new Question($questions[0])); @@ -217,7 +217,7 @@ public function testCommandWithQuestionsButNoInputs() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function ($input, $output) use ($questions, $command) { + $command->setCode(static function ($input, $output) use ($questions, $command) { $helper = $command->getHelper('question'); $helper->ask($input, $output, new ChoiceQuestion('choice', ['a', 'b'])); $helper->ask($input, $output, new Question($questions[0])); @@ -242,7 +242,7 @@ public function testSymfonyStyleCommandWithInputs() ]; $command = new Command('foo'); - $command->setCode(function ($input, $output) use ($questions) { + $command->setCode(static function ($input, $output) use ($questions) { $io = new SymfonyStyle($input, $output); $io->ask($questions[0]); $io->ask($questions[1]); @@ -261,7 +261,7 @@ public function testErrorOutput() $command = new Command('foo'); $command->addArgument('command'); $command->addArgument('foo'); - $command->setCode(function ($input, $output) { + $command->setCode(static function ($input, $output) { $output->getErrorOutput()->write('foo'); }); From 7bbcaf3fdb1e18fa42a7f0b84a10d091c10548f5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 13 Apr 2026 17:27:04 +0200 Subject: [PATCH 6/9] More CS fixes --- Command/TraceableCommand.php | 4 +- Input/ArgvInput.php | 3 +- Output/AnsiColorMode.php | 10 ++-- Tests/Formatter/OutputFormatterTest.php | 66 ++++++++++++++----------- 4 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Command/TraceableCommand.php b/Command/TraceableCommand.php index 9df467b0d..53624d49e 100644 --- a/Command/TraceableCommand.php +++ b/Command/TraceableCommand.php @@ -62,9 +62,7 @@ public function __construct( parent::__construct($command->getName()); // init below enables calling {@see parent::run()} - [$code, $processTitle, $ignoreValidationErrors] = \Closure::bind(function () { - return [$this->code, $this->processTitle, $this->ignoreValidationErrors]; - }, $command, Command::class)(); + [$code, $processTitle, $ignoreValidationErrors] = \Closure::bind(fn () => [$this->code, $this->processTitle, $this->ignoreValidationErrors], $command, Command::class)(); if (\is_callable($code)) { $this->setCode($code); diff --git a/Input/ArgvInput.php b/Input/ArgvInput.php index b5f866689..83b3f0cf6 100644 --- a/Input/ArgvInput.php +++ b/Input/ArgvInput.php @@ -130,9 +130,8 @@ private function parseShortOptionSet(string $name): void $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1)); break; - } else { - $this->addLongOption($option->getName(), null); } + $this->addLongOption($option->getName(), null); } } diff --git a/Output/AnsiColorMode.php b/Output/AnsiColorMode.php index dcdd1d5c4..65037d836 100644 --- a/Output/AnsiColorMode.php +++ b/Output/AnsiColorMode.php @@ -96,11 +96,11 @@ private function degradeHexColorToAnsi8(int $r, int $g, int $b): int } return (int) round(($r - 8) / 247 * 24) + 232; - } else { - return 16 + - (36 * (int) round($r / 255 * 5)) + - (6 * (int) round($g / 255 * 5)) + - (int) round($b / 255 * 5); } + + return 16 + + (36 * (int) round($r / 255 * 5)) + + (6 * (int) round($g / 255 * 5)) + + (int) round($b / 255 * 5); } } diff --git a/Tests/Formatter/OutputFormatterTest.php b/Tests/Formatter/OutputFormatterTest.php index 7f9aac914..b3ec35d2c 100644 --- a/Tests/Formatter/OutputFormatterTest.php +++ b/Tests/Formatter/OutputFormatterTest.php @@ -306,51 +306,59 @@ public function testContentWithLineBreaks() { $formatter = new OutputFormatter(true); - $this->assertEquals(<<format(<<<'EOF' + $this->assertEquals( + <<format(<<<'EOF' some text EOF - )); + ) + ); - $this->assertEquals(<<format(<<<'EOF' + $this->assertEquals( + <<format(<<<'EOF' some text EOF - )); - - $this->assertEquals(<<format(<<<'EOF' + ) + ); + + $this->assertEquals( + <<format(<<<'EOF' some text EOF - )); - - $this->assertEquals(<<format(<<<'EOF' + ) + ); + + $this->assertEquals( + <<format(<<<'EOF' some text more text EOF - )); + ) + ); } public function testFormatAndWrap() From f9f8ca824967b8543fba4906ce9d0f172edcb04d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 13 Apr 2026 17:40:04 +0200 Subject: [PATCH 7/9] CS fixes --- Attribute/Ask.php | 4 +--- Command/TraceableCommand.php | 4 +--- Tests/ApplicationTest.php | 12 ++++-------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Attribute/Ask.php b/Attribute/Ask.php index d4656ee3d..360a08421 100644 --- a/Attribute/Ask.php +++ b/Attribute/Ask.php @@ -95,9 +95,7 @@ public static function tryFrom(\ReflectionParameter|\ReflectionProperty $member, $question->setTimeout($self->timeout); if (!$self->validator && $reflection->isProperty() && 'array' !== $type->getName()) { - $self->validator = function (mixed $value) use ($reflection): mixed { - return $this->{$reflection->getName()} = $value; - }; + $self->validator = fn (mixed $value): mixed => $this->{$reflection->getName()} = $value; } $question->setValidator($self->validator); diff --git a/Command/TraceableCommand.php b/Command/TraceableCommand.php index b6a9a05e4..2cf190e26 100644 --- a/Command/TraceableCommand.php +++ b/Command/TraceableCommand.php @@ -167,9 +167,7 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti public function setCode(callable $code): static { if ($code instanceof InvokableCommand) { - $r = \Closure::bind(function () { - return $this->invokable; - }, $code, InvokableCommand::class)(); + $r = \Closure::bind(fn () => $this->invokable, $code, InvokableCommand::class)(); $this->invokableCommandInfo = [ 'class' => $r->getClosureScopeClass()->name, diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index f3c660be9..a72510226 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -1339,9 +1339,7 @@ public function testAddingOptionWithDuplicateShortcut() ->register('foo') ->setAliases(['f']) ->setDefinition([new InputOption('survey', 'e', InputOption::VALUE_REQUIRED, 'My option with a shortcut.')]) - ->setCode(static function (InputInterface $input, OutputInterface $output): int { - return 0; - }) + ->setCode(static fn (InputInterface $input, OutputInterface $output): int => 0) ; $input = new ArrayInput(['command' => 'foo']); @@ -1362,9 +1360,7 @@ public function testAddingAlreadySetDefinitionElementData($def) $application ->register('foo') ->setDefinition([$def]) - ->setCode(static function (InputInterface $input, OutputInterface $output): int { - return 0; - }) + ->setCode(static fn (InputInterface $input, OutputInterface $output): int => 0) ; $input = new ArrayInput(['command' => 'foo']); @@ -1961,12 +1957,12 @@ public function testFindAlternativesDoesNotLoadSameNamespaceCommandsOnExactMatch 'foo:bar' => static function () use (&$loaded) { $loaded['foo:bar'] = true; - return (new Command('foo:bar'))->setCode(static function (): int { return 0; }); + return (new Command('foo:bar'))->setCode(static fn (): int => 0); }, 'foo' => static function () use (&$loaded) { $loaded['foo'] = true; - return (new Command('foo'))->setCode(static function (): int { return 0; }); + return (new Command('foo'))->setCode(static fn (): int => 0); }, ])); From 91427540e5b2b95dd37421a45cf123557b269989 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 18 Apr 2026 15:16:27 +0200 Subject: [PATCH 8/9] Update XSD references in phpunit.xml.dist files --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ae62ad561..792e75dba 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ Date: Sun, 19 Apr 2026 20:33:56 +0200 Subject: [PATCH 9/9] [7.4] Remove usages of named arguments in tests --- Tests/ApplicationTest.php | 4 ++-- Tests/Command/CompleteCommandTest.php | 2 +- Tests/Exception/RunCommandFailedExceptionTest.php | 4 ++-- Tests/Fixtures/application_test_sigint.php | 2 +- Tests/Messenger/RunCommandMessageHandlerTest.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index a72510226..ed94a7031 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -2485,7 +2485,7 @@ public function testAlarmSubscriberNotCalledForOtherSignals() #[RequiresPhpExtension('pcntl')] public function testAlarmSubscriber() { - $command = new BaseSignableCommand(signal: \SIGALRM); + $command = new BaseSignableCommand(true, \SIGALRM); $subscriber1 = new AlarmEventSubscriber(); $subscriber2 = new AlarmEventSubscriber(); @@ -2703,7 +2703,7 @@ public function testsPreservedHelpOptionWhenItsAnAlternative() #[TestWith([4])] public function testAlarmSubscriberCalledAfterSignalSubscriberAndInheritsExitCode(int|false $exitCode) { - $command = new BaseSignableCommand(signal: \SIGALRM); + $command = new BaseSignableCommand(true, \SIGALRM); $subscriber1 = new class($exitCode) extends SignalEventSubscriber { public function __construct(private int|false $exitCode) diff --git a/Tests/Command/CompleteCommandTest.php b/Tests/Command/CompleteCommandTest.php index a1b94b773..917cb7eb5 100644 --- a/Tests/Command/CompleteCommandTest.php +++ b/Tests/Command/CompleteCommandTest.php @@ -37,7 +37,7 @@ protected function setUp(): void $this->application = new Application(); $this->application->addCommand(new CompleteCommandTest_HelloCommand()); $this->application->getDefinition() - ->addOption(new InputOption('global-option', null, InputOption::VALUE_REQUIRED, suggestedValues: ['foo', 'bar', 'baz'])); + ->addOption(new InputOption('global-option', null, InputOption::VALUE_REQUIRED, '', null, ['foo', 'bar', 'baz'])); $this->command->setApplication($this->application); $this->tester = new CommandTester($this->command); diff --git a/Tests/Exception/RunCommandFailedExceptionTest.php b/Tests/Exception/RunCommandFailedExceptionTest.php index dcdfa2f48..ce8eaf97b 100644 --- a/Tests/Exception/RunCommandFailedExceptionTest.php +++ b/Tests/Exception/RunCommandFailedExceptionTest.php @@ -41,8 +41,8 @@ private static function createException(\Throwable $inner): RunCommandFailedExce $inner, new RunCommandContext( new RunCommandMessage('foo'), - exitCode: Command::FAILURE, - output: 'bar' + Command::FAILURE, + 'bar' ) ); } diff --git a/Tests/Fixtures/application_test_sigint.php b/Tests/Fixtures/application_test_sigint.php index 4a3d4eab0..f312106cf 100644 --- a/Tests/Fixtures/application_test_sigint.php +++ b/Tests/Fixtures/application_test_sigint.php @@ -18,7 +18,7 @@ (new class extends Command { protected function configure(): void { - $this->addArgument('mode', InputArgument::OPTIONAL, default: 'single'); + $this->addArgument('mode', InputArgument::OPTIONAL, '', 'single'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/Tests/Messenger/RunCommandMessageHandlerTest.php b/Tests/Messenger/RunCommandMessageHandlerTest.php index 898492374..e2bb1ea58 100644 --- a/Tests/Messenger/RunCommandMessageHandlerTest.php +++ b/Tests/Messenger/RunCommandMessageHandlerTest.php @@ -60,7 +60,7 @@ public function testExecutesCommandThatThrowsException() public function testExecutesCommandThatCatchesThrownException() { $handler = new RunCommandMessageHandler($this->createApplicationWithCommand()); - $context = $handler(new RunCommandMessage('test:command --throw -v', throwOnFailure: false, catchExceptions: true)); + $context = $handler(new RunCommandMessage('test:command --throw -v', false, true)); $this->assertSame(1, $context->exitCode); $this->assertStringContainsString('[RuntimeException]', $context->output);