Explorar el Código

[DependencyInjection] added a check to ease debugging when a service id is not a string

Fabien Potencier hace 15 años
padre
commit
684ffc83e6
Se han modificado 1 ficheros con 5 adiciones y 0 borrados
  1. 5 0
      src/Symfony/Components/DependencyInjection/Container.php

+ 5 - 0
src/Symfony/Components/DependencyInjection/Container.php

@@ -189,6 +189,11 @@ class Container implements ContainerInterface, \ArrayAccess, \Iterator
    */
   public function getService($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
   {
+    if (!is_string($id))
+    {
+      throw new \InvalidArgumentException(sprintf('A service id should be a string (%s given).', str_replace("\n", '', var_export($id, true))));
+    }
+
     if (isset($this->services[$id]))
     {
       return $this->services[$id];