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:
Sean Harvey 2013-03-21 21:20:35 -07:00
commit 9f35b13b48
2 changed files with 16 additions and 3 deletions

View File

@ -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();

View File

@ -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')),