mirror of
https://github.com/symfony/class-loader.git
synced 2026-04-23 16:58:17 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c36b0fc0ec | |||
| b50ee28ebf | |||
| b6a0da1a46 | |||
| 2f6e0035ea | |||
| 33066c11cc | |||
| 040abef35a | |||
| c00f87add0 |
@@ -84,7 +84,7 @@ class ClassCollectionLoader
|
||||
$files = array();
|
||||
$content = '';
|
||||
foreach ($classes as $class) {
|
||||
if (!class_exists($class) && !interface_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,8 +54,8 @@ class DebugUniversalClassLoader extends UniversalClassLoader
|
||||
if ($file = $this->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
if (!class_exists($class, false) && !interface_exists($class, false)) {
|
||||
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". You probably have a typo in the namespace or the class name.', $class, $file));
|
||||
if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-11
@@ -220,13 +220,15 @@ class UniversalClassLoader
|
||||
// namespaced class name
|
||||
$namespace = substr($class, 0, $pos);
|
||||
foreach ($this->namespaces as $ns => $dirs) {
|
||||
if (0 !== strpos($namespace, $ns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
if (0 === strpos($namespace, $ns)) {
|
||||
$className = substr($class, $pos + 1);
|
||||
$file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
$className = substr($class, $pos + 1);
|
||||
$file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,12 +242,14 @@ class UniversalClassLoader
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
foreach ($this->prefixes as $prefix => $dirs) {
|
||||
if (0 !== strpos($class, $prefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
$file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
$file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "symfony/class-loader",
|
||||
"type": "library",
|
||||
"description": "Symfony ClassLoader Component",
|
||||
"keywords": [],
|
||||
"homepage": "http://symfony.com",
|
||||
"version": "2.0.4",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user