mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-06-29 07:59:31 +02:00
FIX Incorrect parsing of T_STRING values in class spec parsing
* Due to missing break, the T_STRING case would fall through to array. * The values were being added to the wrong variable. * Added missing support for missing null values.
This commit is contained in:
parent
b8a51c3792
commit
d3e4863f52
|
@ -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