Skip to content

Commit 655e8e5

Browse files
committed
change Autoload::loadClass to return if found
1 parent 8fa0095 commit 655e8e5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Autoload.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,16 @@ public static function getClassMap()
203203
* Loads a class' file.
204204
*
205205
* This is the self function registered as an autoload handler.
206+
*
207+
* @return bool
206208
*/
207209
public static function loadClass($class)
208210
{
209211
if ($file = static::findFileForClass($class)) {
210212
includeFile($file);
213+
return true;
211214
}
215+
return false;
212216
}
213217

214218
/**

tests/AutoloadTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ public function testAddPsr4()
2424
$this->assertTrue(class_exists('Foo\\Bar'));
2525
}
2626

27+
/**
28+
* @group psr4
29+
**/
30+
public function testLoadClass()
31+
{
32+
$this->assertFalse(Autoload::loadClass('Foo\\Bar'));
33+
Autoload::addPsr4('Foo', __DIR__.'/fixtures/Foo');
34+
$this->assertTrue(Autoload::loadClass('Foo\\Bar'));
35+
}
36+
2737
/**
2838
* @group psr4
2939
**/

0 commit comments

Comments
 (0)