MINOR: Updated ClassInfo::allClasses() and ::exists() to use $_CLASS_MANIFEST rather than $_ALL_CLASSES. This means results from ClassInfo::allClasses() are now lowercase.

This commit is contained in:
ajshort 2011-02-27 15:20:28 +11:00
parent a0f66099ed
commit 852920237e
2 changed files with 11 additions and 5 deletions

View File

@ -12,16 +12,16 @@ class ClassInfo {
* @todo Improve documentation * @todo Improve documentation
*/ */
static function allClasses() { static function allClasses() {
global $_ALL_CLASSES; global $_CLASS_MANIFEST;
return $_ALL_CLASSES['exists']; return ArrayLib::valuekey(array_keys($_CLASS_MANIFEST));
} }
/** /**
* @todo Improve documentation * @todo Improve documentation
*/ */
static function exists($class) { static function exists($class) {
global $_ALL_CLASSES; global $_CLASS_MANIFEST;
return isset($_ALL_CLASSES['exists'][$class]) ? $_ALL_CLASSES['exists'][$class] : null; return class_exists($class, false) || array_key_exists(strtolower($class), $_CLASS_MANIFEST);
} }
/** /**

View File

@ -5,6 +5,12 @@
*/ */
class ClassInfoTest extends SapphireTest { class ClassInfoTest extends SapphireTest {
public function testExists() {
$this->assertTrue(ClassInfo::exists('Object'));
$this->assertTrue(ClassInfo::exists('ClassInfoTest'));
$this->assertTrue(ClassInfo::exists('stdClass'));
}
function testSubclassesFor() { function testSubclassesFor() {
$this->assertEquals( $this->assertEquals(
ClassInfo::subclassesFor('ClassInfoTest_BaseClass'), ClassInfo::subclassesFor('ClassInfoTest_BaseClass'),