Skip to content

Commit c69e4ab

Browse files
bug #60771 [Runtime] fix compatibility with Symfony 7.4 (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- [Runtime] fix compatibility with Symfony 7.4 | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Since #60394 using `add()` 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. We did something similar before in #60376. Commits ------- d39a7ac fix compatibility with Symfony 7.4
2 parents ac67b6a + d39a7ac commit c69e4ab

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/Symfony/Component/Runtime/SymfonyRuntime.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ public function getRunner(?object $application): RunnerInterface
144144

145145
if (!$application->getName() || !$console->has($application->getName())) {
146146
$application->setName($_SERVER['argv'][0]);
147-
$console->add($application);
147+
if (method_exists($console, 'addCommand')) {
148+
$console->addCommand($application);
149+
} else {
150+
$console->add($application);
151+
}
148152
}
149153

150154
$console->setDefaultCommand($application->getName(), true);

src/Symfony/Component/Runtime/Tests/phpt/application.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
});
2626

2727
$app = new Application();
28-
$app->add($command);
28+
if (method_exists($app, 'addCommand')) {
29+
$app->addCommand($command);
30+
} else {
31+
$app->add($command);
32+
}
2933
$app->setDefaultCommand('go', true);
3034

3135
return $app;

src/Symfony/Component/Runtime/Tests/phpt/command_list.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
$command->setName('my_command');
2424

2525
[$cmd, $args] = $runtime->getResolver(require __DIR__.'/command.php')->resolve();
26-
$app->add($cmd(...$args));
26+
if (method_exists($app, 'addCommand')) {
27+
$app->addCommand($cmd(...$args));
28+
} else {
29+
$app->add($cmd(...$args));
30+
}
2731

2832
return $app;
2933
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy