Compare commits

...

7 Commits

Author SHA1 Message Date
Fabien Potencier c36b0fc0ec [ClassLoader] fixed usage of trait_exists() 2011-10-03 18:02:59 +02:00
Igor Wiedler b50ee28ebf [composer] add composer.json 2011-09-27 00:55:43 +02:00
Josef Cech b6a0da1a46 [ClassLoader] Fixed state when trait_exists doesn't exists 2011-09-25 19:25:50 +02:00
Fabien Potencier 2f6e0035ea [ClassLoader] added support for PHP 5.4 traits 2011-09-22 09:31:50 +02:00
Fabien Potencier 33066c11cc [ClassLoader] fixed CS 2011-08-13 10:30:20 +02:00
Baptiste Clavié 040abef35a got an if-condition out of unnecessary loops in Symfony\Component\ClassLoader\UniversalClassLoader 2011-08-11 16:23:36 +03:00
Jordi Boggiano c00f87add0 [ClassLoader] Improve exception messages of the debug class loader 2011-07-31 22:59:22 +02:00
4 changed files with 40 additions and 14 deletions
+1 -1
View File
@@ -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));
}
+2 -2
View File
@@ -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
View File
@@ -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;
}
}
}
+22
View 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"
}
}