diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 5aa6680e7e..6a9c923768 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -226,7 +226,16 @@ class AutowirePass extends AbstractRecursivePass if ($parameter->isDefaultValueAvailable()) { $value = $parameter->getDefaultValue(); } elseif (!$parameter->allowsNull()) { - throw new AutowiringFailedException($this->currentId, $failureMessage); + if (\function_exists('xdebug_disable')) { + xdebug_disable(); + } + try { + throw new AutowiringFailedException($this->currentId, $failureMessage); + } finally { + if (\function_exists('xdebug_enable')) { + xdebug_enable(); + } + } } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php index e39cd4981a..bd9c340eda 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php @@ -84,10 +84,15 @@ class PassConfig new RemoveUnusedDefinitionsPass(), new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()), new AnalyzeServiceReferencesPass(), - new DefinitionErrorExceptionPass(), new CheckExceptionOnInvalidReferenceBehaviorPass(), new ResolveHotPathPass(), ]]; + + $this->afterRemovingPasses = [ + 100 => [ + new DefinitionErrorExceptionPass(), + ], + ]; } /** diff --git a/src/Symfony/Component/DependencyInjection/Exception/AutowiringFailedException.php b/src/Symfony/Component/DependencyInjection/Exception/AutowiringFailedException.php index 05f134a942..be2bd26dca 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/AutowiringFailedException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/AutowiringFailedException.php @@ -47,7 +47,11 @@ class AutowiringFailedException extends RuntimeException $messageCallback = $this->messageCallback; $this->messageCallback = null; - return $this->message = $messageCallback(); + try { + return $this->message = $messageCallback(); + } catch (\Throwable $e) { + return $this->message = $e->getMessage(); + } } }; }