Add support for Application::setCatchErrors in symfony 6.4+, refs symfony/symfony#50420
parent
ff70ab7ce9
commit
f4738d97b7
|
@ -87,6 +87,10 @@ class Application extends BaseApplication
|
|||
|
||||
public function __construct(string $name = 'Composer', string $version = '')
|
||||
{
|
||||
if (method_exists($this, 'setCatchErrors')) {
|
||||
$this->setCatchErrors(true);
|
||||
}
|
||||
|
||||
static $shutdownRegistered = false;
|
||||
if ($version === '') {
|
||||
$version = Composer::getVersion();
|
||||
|
@ -395,9 +399,10 @@ class Application extends BaseApplication
|
|||
|
||||
$this->hintCommonErrors($e, $output);
|
||||
|
||||
// symfony/console does not handle \Error subtypes so we have to renderThrowable ourselves
|
||||
// symfony/console <6.4 does not handle \Error subtypes so we have to renderThrowable ourselves
|
||||
// instead of rethrowing those for consumption by the parent class
|
||||
if (!$e instanceof \Exception) {
|
||||
// can be removed when Composer supports PHP 8.1+
|
||||
if (!method_exists($this, 'setCatchErrors') && !$e instanceof \Exception) {
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$this->renderThrowable($e, $output->getErrorOutput());
|
||||
} else {
|
||||
|
|
|
@ -277,6 +277,9 @@ class EventDispatcher
|
|||
|
||||
$app = new Application();
|
||||
$app->setCatchExceptions(false);
|
||||
if (method_exists($app, 'setCatchErrors')) {
|
||||
$app->setCatchErrors(false);
|
||||
}
|
||||
$app->setAutoExit(false);
|
||||
$cmd = new $className($event->getName());
|
||||
$app->add($cmd);
|
||||
|
|
|
@ -53,6 +53,9 @@ class DocumentationTest extends TestCase
|
|||
{
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
if (method_exists($application, 'setCatchErrors')) {
|
||||
$application->setCatchErrors(false);
|
||||
}
|
||||
$application->setCatchExceptions(false);
|
||||
|
||||
$description = new ApplicationDescription($application);
|
||||
|
|
|
@ -198,6 +198,9 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
|||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
if (method_exists($application, 'setCatchErrors')) {
|
||||
$application->setCatchErrors(false);
|
||||
}
|
||||
|
||||
return new ApplicationTester($application);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue