Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix ClassLoader to respect foreign class loaders

  • Loading branch information...
commit 3ea7a3702a2b2f7e54550a665bed27701270e007 1 parent 583b0e1
Jan Dolecek authored December 27, 2011
2  lib/Doctrine/Common/ClassLoader.php
@@ -236,7 +236,7 @@ public static function classExists($className)
236 236
             }
237 237
         }
238 238
 
239  
-        return false;
  239
+        return class_exists($className, false); // test again since loader may have loaded it while not returning true
240 240
     }
241 241
 
242 242
     /**
12  tests/Doctrine/Tests/Common/ClassLoaderTest.php
@@ -42,4 +42,16 @@ public function testGetClassLoader()
42 42
         $this->assertNull(ClassLoader::getClassLoader('This\Class\Does\Not\Exist'));
43 43
         $cl->unregister();
44 44
     }
  45
+
  46
+    public function testForeignClassLoader()
  47
+    {
  48
+        $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\ClassE'));
  49
+        $badLoader = function($className) {
  50
+            require __DIR__ . '/ClassLoaderTest/ClassE.php';
  51
+            // do not return anything like most classloaders
  52
+        };
  53
+        spl_autoload_register($badLoader);
  54
+        $this->assertTrue(ClassLoader::classExists('ClassLoaderTest\ClassE'));
  55
+        spl_autoload_unregister($badLoader);
  56
+    }
45 57
 }
5  tests/Doctrine/Tests/Common/ClassLoaderTest/ClassE.php
... ...
@@ -0,0 +1,5 @@
  1
+<?php
  2
+
  3
+namespace ClassLoaderTest;
  4
+
  5
+class ClassE {}

0 notes on commit 3ea7a37

Please sign in to comment.
Something went wrong with that request. Please try again.