Added an error message in the DebugClassLoader when using / instead of \.

This commit is contained in:
Christophe Coevoet 2013-01-18 20:26:53 +01:00 committed by Fabien Potencier
parent 9223c5acfd
commit 11aaa2e672

View File

@ -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));
}