diff --git a/src/ClassMapAutoloader.php b/src/ClassMapAutoloader.php index f5d2770..8b57b5a 100644 --- a/src/ClassMapAutoloader.php +++ b/src/ClassMapAutoloader.php @@ -134,16 +134,17 @@ public function getAutoloadMap() } /** - * Defined by Autoloadable - * - * @param string $class - * @return void + * {@inheritDoc} */ public function autoload($class) { if (isset($this->map[$class])) { require_once $this->map[$class]; + + return $class; } + + return false; } /** diff --git a/test/ClassMapAutoloaderTest.php b/test/ClassMapAutoloaderTest.php index 4872032..a6c5b51 100644 --- a/test/ClassMapAutoloaderTest.php +++ b/test/ClassMapAutoloaderTest.php @@ -147,7 +147,8 @@ public function testAutoloadLoadsClasses() { $map = array('ZendTest\UnusualNamespace\ClassMappedClass' => __DIR__ . '/TestAsset/ClassMappedClass.php'); $this->loader->registerAutoloadMap($map); - $this->loader->autoload('ZendTest\UnusualNamespace\ClassMappedClass'); + $loaded = $this->loader->autoload('ZendTest\UnusualNamespace\ClassMappedClass'); + $this->assertSame('ZendTest\UnusualNamespace\ClassMappedClass', $loaded); $this->assertTrue(class_exists('ZendTest\UnusualNamespace\ClassMappedClass', false)); } @@ -155,7 +156,7 @@ public function testIgnoresClassesNotInItsMap() { $map = array('ZendTest\UnusualNamespace\ClassMappedClass' => __DIR__ . '/TestAsset/ClassMappedClass.php'); $this->loader->registerAutoloadMap($map); - $this->loader->autoload('ZendTest\UnusualNamespace\UnMappedClass'); + $this->assertFalse($this->loader->autoload('ZendTest\UnusualNamespace\UnMappedClass')); $this->assertFalse(class_exists('ZendTest\UnusualNamespace\UnMappedClass', false)); } @@ -172,7 +173,8 @@ public function testCanLoadClassMapFromPhar() { $map = 'phar://' . __DIR__ . '/_files/classmap.phar/test/.//../autoload_classmap.php'; $this->loader->registerAutoloadMap($map); - $this->loader->autoload('some\loadedclass'); + $loaded = $this->loader->autoload('some\loadedclass'); + $this->assertSame('some\loadedclass', $loaded); $this->assertTrue(class_exists('some\loadedclass', false)); // will not register duplicate, even with a different relative path