mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1322 from ajshort/pulls/class-spec-parsing
FIX Incorrect parsing of T_STRING values in class spec parsing
This commit is contained in:
commit
9f35b13b48
@ -194,11 +194,13 @@ abstract class Object {
|
||||
|
||||
case T_STRING:
|
||||
switch($token[1]) {
|
||||
case 'true': $args[] = true; break;
|
||||
case 'false': $args[] = false; break;
|
||||
case 'true': $bucket[] = true; break;
|
||||
case 'false': $bucket[] = false; break;
|
||||
case 'null': $bucket[] = null; break;
|
||||
default: throw new Exception("Bad T_STRING arg '{$token[1]}'");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case T_ARRAY:
|
||||
// Add an empty array to the bucket
|
||||
$bucket[] = array();
|
||||
|
@ -349,6 +349,17 @@ class ObjectTest extends SapphireTest {
|
||||
array('Versioned',array('Stage\'Stage,Live\'Live', 'Live')),
|
||||
Object::parse_class_spec("Versioned('Stage\'Stage,Live\'Live','Live')")
|
||||
);
|
||||
|
||||
// True, false and null values
|
||||
$this->assertEquals(
|
||||
array('ClassName', array('string', true, array('string', false))),
|
||||
Object::parse_class_spec('ClassName("string", true, array("string", false))')
|
||||
);
|
||||
$this->assertEquals(
|
||||
array('ClassName', array(true, false, null)),
|
||||
Object::parse_class_spec('ClassName(true, false, null)')
|
||||
);
|
||||
|
||||
// Array
|
||||
$this->assertEquals(
|
||||
array('Enum',array(array('Accepted', 'Pending', 'Declined', 'Unsubmitted'), 'Unsubmitted')),
|
||||
|
Loading…
Reference in New Issue
Block a user