From 11aaa2e672940af08a8a696ce3bf3eba710bfdd0 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 18 Jan 2013 20:26:53 +0100 Subject: [PATCH] Added an error message in the DebugClassLoader when using / instead of \. --- src/Symfony/Component/ClassLoader/DebugClassLoader.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/ClassLoader/DebugClassLoader.php b/src/Symfony/Component/ClassLoader/DebugClassLoader.php index dbfb5ab1e3..54fe23eabb 100644 --- a/src/Symfony/Component/ClassLoader/DebugClassLoader.php +++ b/src/Symfony/Component/ClassLoader/DebugClassLoader.php @@ -82,6 +82,10 @@ class DebugClassLoader require $file; if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { + if (false !== strpos($class, '/')) { + throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".')); + } + throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); }