[ClassLoader] Fixed state when trait_exists doesn't exists
This commit is contained in:
parent
369d4da4eb
commit
85ed5c67dc
@ -84,7 +84,7 @@ class ClassCollectionLoader
|
||||
$files = array();
|
||||
$content = '';
|
||||
foreach ($classes as $class) {
|
||||
if (!class_exists($class) && !interface_exists($class) && function_exists('trait_exists') && !trait_exists($class)) {
|
||||
if (!class_exists($class) && !interface_exists($class) && (!function_exists('trait_exists') || !trait_exists($class))) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class DebugUniversalClassLoader extends UniversalClassLoader
|
||||
if ($file = $this->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
if (!class_exists($class, false) && !interface_exists($class, false) && function_exists('trait_exists') && !trait_exists($class)) {
|
||||
if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class))) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -63,4 +63,12 @@ EOF;
|
||||
|
||||
$this->assertEquals($expected, ClassCollectionLoader::fixNamespaceDeclarations($source));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testUnableToLoadClassException()
|
||||
{
|
||||
ClassCollectionLoader::load(array('SomeNotExistingClass'), '', 'foo', false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user