mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
a0f66099ed
commit
852920237e
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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'),
|
||||||
|
Loading…
Reference in New Issue
Block a user