[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()) {
|
if ($parameter->isDefaultValueAvailable()) {
|
||||||
$value = $parameter->getDefaultValue();
|
$value = $parameter->getDefaultValue();
|
||||||
} elseif (!$parameter->allowsNull()) {
|
} 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,10 +84,15 @@ class PassConfig
|
|||||||
new RemoveUnusedDefinitionsPass(),
|
new RemoveUnusedDefinitionsPass(),
|
||||||
new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()),
|
new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()),
|
||||||
new AnalyzeServiceReferencesPass(),
|
new AnalyzeServiceReferencesPass(),
|
||||||
new DefinitionErrorExceptionPass(),
|
|
||||||
new CheckExceptionOnInvalidReferenceBehaviorPass(),
|
new CheckExceptionOnInvalidReferenceBehaviorPass(),
|
||||||
new ResolveHotPathPass(),
|
new ResolveHotPathPass(),
|
||||||
]];
|
]];
|
||||||
|
|
||||||
|
$this->afterRemovingPasses = [
|
||||||
|
100 => [
|
||||||
|
new DefinitionErrorExceptionPass(),
|
||||||
|
],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,11 @@ class AutowiringFailedException extends RuntimeException
|
|||||||
$messageCallback = $this->messageCallback;
|
$messageCallback = $this->messageCallback;
|
||||||
$this->messageCallback = null;
|
$this->messageCallback = null;
|
||||||
|
|
||||||
return $this->message = $messageCallback();
|
try {
|
||||||
|
return $this->message = $messageCallback();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->message = $e->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user