From 0b3d980d553552fe9c010e0db5d1a1237af0c8f9 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 7 May 2025 23:08:36 +0200 Subject: [PATCH] fix tests Since #60076 using a closure as the command code that does not return an integer is deprecated. This means that our tests can trigger deprecations on older branches when the high deps job is run. This usually is not an issue as we silence them with the `SYMFONY_DEPRECATIONS_HELPER` env var. However, phpt tests are run in a child process where the deprecation error handler of the PHPUnit bridge doesn't step in. Thus, for them deprecations are not silenced leading to failures. --- src/Symfony/Component/Runtime/Tests/phpt/application.php | 4 +++- src/Symfony/Component/Runtime/Tests/phpt/command.php | 4 +++- .../phpt/dotenv_overload_command_debug_exists_0_to_1.php | 4 +++- .../phpt/dotenv_overload_command_debug_exists_1_to_0.php | 4 +++- .../Runtime/Tests/phpt/dotenv_overload_command_env_exists.php | 4 +++- .../Runtime/Tests/phpt/dotenv_overload_command_no_debug.php | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Runtime/Tests/phpt/application.php b/src/Symfony/Component/Runtime/Tests/phpt/application.php index 1e1014e9f3e5a..ca2de555edfb7 100644 --- a/src/Symfony/Component/Runtime/Tests/phpt/application.php +++ b/src/Symfony/Component/Runtime/Tests/phpt/application.php @@ -18,8 +18,10 @@ return function (array $context) { $command = new Command('go'); - $command->setCode(function (InputInterface $input, OutputInterface $output) use ($context) { + $command->setCode(function (InputInterface $input, OutputInterface $output) use ($context): int { $output->write('OK Application '.$context['SOME_VAR']); + + return 0; }); $app = new Application(); diff --git a/src/Symfony/Component/Runtime/Tests/phpt/command.php b/src/Symfony/Component/Runtime/Tests/phpt/command.php index 3a5fa11e00000..e307d195b113e 100644 --- a/src/Symfony/Component/Runtime/Tests/phpt/command.php +++ b/src/Symfony/Component/Runtime/Tests/phpt/command.php @@ -19,7 +19,9 @@ return function (Command $command, InputInterface $input, OutputInterface $output, array $context) { $command->addOption('hello', 'e', InputOption::VALUE_REQUIRED, 'How should I greet?', 'OK'); - return $command->setCode(function () use ($input, $output, $context) { + return $command->setCode(function () use ($input, $output, $context): int { $output->write($input->getOption('hello').' Command '.$context['SOME_VAR']); + + return 0; }); }; diff --git a/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_0_to_1.php b/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_0_to_1.php index af6409dda62bc..2968e37ea02f4 100644 --- a/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_0_to_1.php +++ b/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_0_to_1.php @@ -20,6 +20,8 @@ require __DIR__.'/autoload.php'; -return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void { +return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): int { $output->writeln($context['DEBUG_ENABLED']); + + return 0; }); diff --git a/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_1_to_0.php b/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_1_to_0.php index 78a0bf29448b8..1f2fa3590e16f 100644 --- a/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_1_to_0.php +++ b/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_1_to_0.php @@ -20,6 +20,8 @@ require __DIR__.'/autoload.php'; -return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void { +return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): int { $output->writeln($context['DEBUG_MODE']); + + return 0; }); diff --git a/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_env_exists.php b/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_env_exists.php index 3e72372e5af06..8587f20f2382b 100644 --- a/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_env_exists.php +++ b/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_env_exists.php @@ -20,6 +20,8 @@ require __DIR__.'/autoload.php'; -return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void { +return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): int { $output->writeln($context['ENV_MODE']); + + return 0; }); diff --git a/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_no_debug.php b/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_no_debug.php index 3fe4f44d7967b..4ab7694298f95 100644 --- a/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_no_debug.php +++ b/src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_no_debug.php @@ -19,6 +19,8 @@ require __DIR__.'/autoload.php'; -return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void { +return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): int { $output->writeln($context['DEBUG_ENABLED']); + + return 0; });