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

This commit is contained in:
Fabien Potencier 2010-01-19 13:29:28 +01:00
parent c0152e1bba
commit 684ffc83e6
1 changed files with 5 additions and 0 deletions

View File

@ -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];