From 09993265c2ed3895bf01dda1e8a927bfe23c695c Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Thu, 14 Apr 2016 16:16:50 +0200 Subject: [PATCH] better error message if factory class is empty --- .../Component/DependencyInjection/Dumper/PhpDumper.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index a8894f39e2f15..57b0f086c0aa4 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -330,7 +330,7 @@ private function addServiceInlinedDefinitions($id, $definition) throw new ServiceCircularReferenceException($id, array($id)); } - $code .= $this->addNewInstance($sDefinition, '$'.$name, ' = '); + $code .= $this->addNewInstance($sDefinition, '$'.$name, ' = ', $id); if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) { $code .= $this->addServiceMethodCalls(null, $sDefinition, $name); @@ -404,7 +404,7 @@ private function addServiceInstance($id, $definition) $instantiation .= ' = '; } - $code = $this->addNewInstance($definition, $return, $instantiation); + $code = $this->addNewInstance($definition, $return, $instantiation, $id); if (!$simple) { $code .= "\n"; @@ -692,7 +692,7 @@ private function addServices() return $publicServices.$privateServices; } - private function addNewInstance(Definition $definition, $return, $instantiation) + private function addNewInstance(Definition $definition, $return, $instantiation, $id) { $class = $this->dumpValue($definition->getClass()); @@ -716,6 +716,10 @@ private function addNewInstance(Definition $definition, $return, $instantiation) $class = $this->dumpValue($callable[0]); // If the class is a string we can optimize call_user_func away if (strpos($class, "'") === 0) { + if ("''" === $class) { + throw new RuntimeException(sprintf('Cannot dump definition: The "%s" service is defined to be created by a factory but is missing the service reference, did you forget to define the factory service id or class?', $id)); + } + return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $callable[1], $arguments ? implode(', ', $arguments) : ''); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy