[DependencyInjection] Fail when dumping a Definition with no class nor factory
This commit is contained in:
parent
18716153ee
commit
23ad4ad133
@ -1210,11 +1210,6 @@ EOF;
|
|||||||
foreach ($value->getArguments() as $argument) {
|
foreach ($value->getArguments() as $argument) {
|
||||||
$arguments[] = $this->dumpValue($argument);
|
$arguments[] = $this->dumpValue($argument);
|
||||||
}
|
}
|
||||||
$class = $this->dumpValue($value->getClass());
|
|
||||||
|
|
||||||
if (false !== strpos($class, '$')) {
|
|
||||||
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $value->getFactoryMethod()) {
|
if (null !== $value->getFactoryMethod()) {
|
||||||
if (null !== $value->getFactoryClass()) {
|
if (null !== $value->getFactoryClass()) {
|
||||||
@ -1228,6 +1223,15 @@ EOF;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$class = $value->getClass();
|
||||||
|
if (null === $class) {
|
||||||
|
throw new RuntimeException('Cannot dump definitions which have no class nor factory.');
|
||||||
|
}
|
||||||
|
$class = $this->dumpValue($class);
|
||||||
|
if (false !== strpos($class, '$')) {
|
||||||
|
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
|
||||||
|
}
|
||||||
|
|
||||||
return sprintf('new \\%s(%s)', substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
|
return sprintf('new \\%s(%s)', substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
|
||||||
} elseif ($value instanceof Variable) {
|
} elseif ($value instanceof Variable) {
|
||||||
return '$'.$value;
|
return '$'.$value;
|
||||||
|
Reference in New Issue
Block a user