mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX Handle namespaced classes in Object::parse_class_spec()
This commit is contained in:
parent
618a3d0314
commit
94be5c6d87
@ -164,12 +164,19 @@ abstract class Object {
|
||||
// Keep track of the current bucket that we're putting data into
|
||||
$bucket = &$args;
|
||||
$bucketStack = array();
|
||||
$had_ns = false;
|
||||
|
||||
foreach($tokens as $token) {
|
||||
$tName = is_array($token) ? $token[0] : $token;
|
||||
// Get the class naem
|
||||
if($class == null && is_array($token) && $token[0] == T_STRING) {
|
||||
$class = $token[1];
|
||||
} elseif(is_array($token) && $token[0] == T_NS_SEPARATOR) {
|
||||
$class .= $token[1];
|
||||
$had_ns = true;
|
||||
} elseif ($had_ns && is_array($token) && $token[0] == T_STRING) {
|
||||
$class .= $token[1];
|
||||
$had_ns = false;
|
||||
// Get arguments
|
||||
} else if(is_array($token)) {
|
||||
switch($token[0]) {
|
||||
|
@ -361,6 +361,16 @@ class ObjectTest extends SapphireTest {
|
||||
Object::parse_class_spec(
|
||||
"Enum(array('Accepted', 'Pending', 'Declined', array('UnsubmittedA','UnsubmittedB')), 'Unsubmitted')")
|
||||
);
|
||||
// Namespaced class
|
||||
$this->assertEquals(
|
||||
array('Test\MyClass', array()),
|
||||
Object::parse_class_spec('Test\MyClass')
|
||||
);
|
||||
// Fully qualified namespaced class
|
||||
$this->assertEquals(
|
||||
array('\Test\MyClass', array()),
|
||||
Object::parse_class_spec('\Test\MyClass')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user