Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Do not exit from loadClass() early #5783

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion library/Zend/Loader/StandardAutoloader.php
Expand Up @@ -302,7 +302,6 @@ protected function loadClass($class, $type)
if (file_exists($filename)) {
return include $filename;
}
return false;
}
}
return false;
Expand Down
9 changes: 9 additions & 0 deletions tests/ZendTest/Loader/StandardAutoloaderTest.php
Expand Up @@ -190,4 +190,13 @@ public function testCanTellAutoloaderToRegisterZendNamespaceAtInstantiation()
$this->assertAttributeEquals($expected, 'namespaces', $loader);
}

public function testWillLoopThroughAllNamespacesUntilMatchIsFoundWhenAutoloading()
{
$loader = new StandardAutoloader();
$loader->registerNamespace('ZendTest\Loader\TestAsset\Parent', __DIR__ . '/TestAsset/Parent');
$loader->registerNamespace('ZendTest\Loader\TestAsset\Parent\Child', __DIR__ . '/TestAsset/Child');
$result = $loader->autoload('ZendTest\Loader\TestAsset\Parent\Child\Subclass');
$this->assertTrue($result !== false);
$this->assertTrue(class_exists('ZendTest\Loader\TestAsset\Parent\Child\Subclass', false));
}
}
17 changes: 17 additions & 0 deletions tests/ZendTest/Loader/TestAsset/Child/Subclass.php
@@ -0,0 +1,17 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\Loader\TestAsset\Parent\Child;

/**
* @group Loader
*/
class Subclass
{
}
Empty file.