10000 merged branch szicsu/UniversalClassLoader-FIX (PR #5692) · s7ntech/symfony@4e971e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e971e7

Browse files
committed
merged branch szicsu/UniversalClassLoader-FIX (PR symfony#5692)
This PR was merged into the master branch. Commits ------- f66f110 FIX [2.1][ClassLoader]UniversalClassLoader not working with AnnotationRegistry::registerLoader Discussion ---------- [2.1][ClassLoader]UniversalClassLoader not working with AnnotationRe... Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: ~ Todo: ~ License of the code: MIT Documentation PR: ~ The Doctrine\Common\Annotations\AnnotationRegistry::loadAnnotationClass examines the returning value of the loader and the load is successful only if the loader returns with "TRUE" value. This is how method Symfony\Component\ClassLoader\ClassLoader::loadClass works, but it is not true for Symfony\Component\ClassLoader\UniversalClassLoader::loadClass. --------------------------------------------------------------------------- by sstok at 2012-10-08T09:25:39Z As this is a bug fix it should be done on 2.0 --------------------------------------------------------------------------- by stof at 2012-10-08T12:49:42Z It is not a bugfix. Nothing enforces an autoloader to return a boolean in PHP. And Symfony works with the annotation registry since 1.5 year (when it was introduced): https://github.com/symfony/symfony-standard/blob/2.0/app/autoload.php#L34-38 Btw, if you are using 2.1, I would recommend you to use the new ClassLoader instead of the UniversalClassLoader to autoload PSR-0 libraries. It has a simpler API (and returns the boolean needed by Doctrine) while supporting the same classes than the UniversalClasssLoader (both of them are supporting PSR-0 and nothing else)
2 parents ddcf71c + f66f110 commit 4e971e7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Symfony/Component/ClassLoader/Tests/UniversalClassLoaderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testLoadClass($className, $testClassName, $message)
2323
$loader = new UniversalClassLoader();
2424
$loader->registerNamespace('Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
2525
$loader->registerPrefix('Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
26-
$loader->loadClass($testClassName);
26+
$this->assertTrue($loader->loadClass($testClassName));
2727
$this->assertTrue(class_exists($className), $message);
2828
}
2929

@@ -92,7 +92,7 @@ public function testLoadClassFromFallback($className, $testClassName, $message)
8000
9292
$loader->registerPrefix('Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
9393
$loader->registerNamespaceFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback'));
9494
$loader->registerPrefixFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/fallback'));
95-
$loader->loadClass($testClassName);
95+
$this->assertTrue($loader->loadClass($testClassName));
9696
$this->assertTrue(class_exists($className), $message);
9797
}
9898

@@ -128,7 +128,7 @@ public function testLoadClassNamespaceCollision($namespaces, $className, $messag
128128
$loader = new UniversalClassLoader();
129129
$loader->registerNamespaces($namespaces);
130130

131-
$loader->loadClass($className);
131+
$this->assertTrue($loader->loadClass($className));
132132
$this->assertTrue(class_exists($className), $message);
133133
}
134134

@@ -178,7 +178,7 @@ public function testLoadClassPrefixCollision($prefixes, $className, $message)
178178
$loader = new UniversalClassLoader();
179179
$loader->registerPrefixes($prefixes);
180180

181-
$loader->loadClass($className);
181+
$this->assertTrue($loader->loadClass($className));
182182
$this->assertTrue(class_exists($className), $message);
183183
}
184184

src/Symfony/Component/ClassLoader/UniversalClassLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,15 @@ public function register($prepend = false)
242242
* Loads the given class or interface.
243243
*
244244
* @param string $class The name of the class
245+
*
246+
* @return Boolean|null True, if loaded
245247
*/
246248
public function loadClass($class)
247249
{
248250
if ($file = $this->findFile($class)) {
249251
require $file;
252+
253+
return true;
250254
}
251255
}
252256

0 commit comments

Comments
 (0)
0