[DI] fix dumping errored definitions

This commit is contained in:
Nicolas Grekas 2020-03-04 16:44:30 +01:00
parent 4103a6ebd2
commit 8179928336
2 changed files with 24 additions and 13 deletions

View File

@ -794,6 +794,11 @@ EOF;
EOF;
}
if ($definition->hasErrors() && $e = $definition->getErrors()) {
$this->addThrow = true;
$code .= sprintf(" \$this->throw(%s);\n", $this->export(reset($e)));
} else {
$this->serviceCalls = [];
$this->inlinedDefinitions = $this->getDefinitionsFromArguments([$definition], null, $this->serviceCalls);
@ -808,6 +813,7 @@ EOF;
$code .= $this->addServiceInclude($id, $definition);
$code .= $this->addInlineService($id, $definition);
}
if ($asFile) {
$code = implode("\n", array_map(function ($line) { return $line ? substr($line, 8) : $line; }, explode("\n", $code)));

View File

@ -120,6 +120,11 @@ class Symfony_DI_PhpDumper_Service_Locator_Argument extends Container
*/
protected function getFoo4Service()
{
return $this->privates['foo4'] = new \stdClass();
$this->throw('BOOM');
}
protected function throw($message)
{
throw new RuntimeException($message);
}
}