Skip to content

Commit 12f834c

Browse files
[DependencyInjection] Fail when dumping a Definition with no class nor factory
1 parent a6b7a4b commit 12f834c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Dumper/PhpDumper.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,11 +1210,6 @@ private function dumpValue($value, $interpolate = true)
12101210
foreach ($value->getArguments() as $argument) {
12111211
$arguments[] = $this->dumpValue($argument);
12121212
}
1213-
$class = $this->dumpValue($value->getClass());
1214-
1215-
if (false !== strpos($class, '$')) {
1216-
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
1217-
}
12181213

12191214
if (null !== $value->getFactoryMethod()) {
12201215
if (null !== $value->getFactoryClass()) {
@@ -1228,6 +1223,15 @@ private function dumpValue($value, $interpolate = true)
12281223
}
12291224
}
12301225

1226+
$class = $value->getClass();
1227+
if (null === $class) {
1228+
throw new RuntimeException('Cannot dump definitions which have no class nor factory.');
1229+
}
1230+
$class = $this->dumpValue($class);
1231+
if (false !== strpos($class, '$')) {
1232+
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
1233+
}
1234+
12311235
return sprintf('new \\%s(%s)', substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
12321236
} elseif ($value instanceof Variable) {
12331237
return '$'.$value;

0 commit comments

Comments
 (0)