[DI] fix casting AutowiringFailedException to string when its callback throws
This commit is contained in:
parent
d7fdcb1a5d
commit
d57a148b8b
@ -226,7 +226,16 @@ class AutowirePass extends AbstractRecursivePass
|
||||
if ($parameter->isDefaultValueAvailable()) {
|
||||
$value = $parameter->getDefaultValue();
|
||||
} elseif (!$parameter->allowsNull()) {
|
||||
if (\function_exists('xdebug_disable')) {
|
||||
xdebug_disable();
|
||||
}
|
||||
try {
|
||||
throw new AutowiringFailedException($this->currentId, $failureMessage);
|
||||
} finally {
|
||||
if (\function_exists('xdebug_enable')) {
|
||||
xdebug_enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,11 @@ class AutowiringFailedException extends RuntimeException
|
||||
$messageCallback = $this->messageCallback;
|
||||
$this->messageCallback = null;
|
||||
|
||||
try {
|
||||
return $this->message = $messageCallback();
|
||||
} catch (\Throwable $e) {
|
||||
return $this->message = $e->getMessage();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user