mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Parsing heredoc, nowdoc & comments in ConfigStaticManifest
This commit is contained in:
parent
e6352dffbb
commit
60b72edfba
@ -268,6 +268,9 @@ class SS_ConfigStaticManifest_Parser {
|
|||||||
else if($type == ';' || $type == ',' || $type == '=') {
|
else if($type == ';' || $type == ',' || $type == '=') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if($type == T_COMMENT) {
|
||||||
|
// NOP
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
user_error('Unexpected token when building static manifest: '.print_r($token, true), E_USER_ERROR);
|
user_error('Unexpected token when building static manifest: '.print_r($token, true), E_USER_ERROR);
|
||||||
}
|
}
|
||||||
@ -317,7 +320,7 @@ class SS_ConfigStaticManifest_Parser {
|
|||||||
|
|
||||||
$this->statics[$class][$variable] = array(
|
$this->statics[$class][$variable] = array(
|
||||||
'access' => $access,
|
'access' => $access,
|
||||||
'value' => eval('return '.$value.';')
|
'value' => eval('return '.trim($value).";\n")
|
||||||
);
|
);
|
||||||
|
|
||||||
if($token == ',') $this->parseStatic($access, $class);
|
if($token == ',') $this->parseStatic($access, $class);
|
||||||
|
@ -20,9 +20,20 @@ class ConfigStaticManifestTest extends SapphireTest {
|
|||||||
static $sfloat = 2.5;
|
static $sfloat = 2.5;
|
||||||
static $sstring = 'string';
|
static $sstring = 'string';
|
||||||
static $sarray = array(1, 2, array(3, 4), 5);
|
static $sarray = array(1, 2, array(3, 4), 5);
|
||||||
|
static $sheredoc = <<<DOC
|
||||||
|
heredoc
|
||||||
|
DOC;
|
||||||
|
static $snowdoc = <<<'DOC'
|
||||||
|
nowdoc
|
||||||
|
DOC;
|
||||||
|
|
||||||
// Assigning multiple values
|
// Assigning multiple values
|
||||||
static $onone, $onull = null, $oint = 1, $ofloat = 2.5, $ostring = 'string', $oarray = array(1, 2, array(3, 4), 5);
|
static $onone, $onull = null, $oint = 1, $ofloat = 2.5, $ostring = 'string', $oarray = array(1, 2, array(3, 4), 5), $oheredoc = <<<DOC
|
||||||
|
heredoc
|
||||||
|
DOC
|
||||||
|
, $onowdoc = <<<'DOC'
|
||||||
|
nowdoc
|
||||||
|
DOC;
|
||||||
|
|
||||||
static
|
static
|
||||||
$mnone,
|
$mnone,
|
||||||
@ -34,7 +45,17 @@ class ConfigStaticManifestTest extends SapphireTest {
|
|||||||
1, 2,
|
1, 2,
|
||||||
array(3, 4),
|
array(3, 4),
|
||||||
5
|
5
|
||||||
);
|
),
|
||||||
|
$mheredoc = <<<DOC
|
||||||
|
heredoc
|
||||||
|
DOC
|
||||||
|
,
|
||||||
|
$mnowdoc = <<<'DOC'
|
||||||
|
nowdoc
|
||||||
|
DOC;
|
||||||
|
|
||||||
|
|
||||||
|
static /* Has comment inline */ $commented_int = 1, /* And here */ $commented_string = 'string';
|
||||||
|
|
||||||
// Should ignore static methpds
|
// Should ignore static methpds
|
||||||
static function static_method() {}
|
static function static_method() {}
|
||||||
@ -90,6 +111,8 @@ class ConfigStaticManifestTest extends SapphireTest {
|
|||||||
'float',
|
'float',
|
||||||
'string',
|
'string',
|
||||||
'array',
|
'array',
|
||||||
|
'heredoc',
|
||||||
|
'nowdoc'
|
||||||
);
|
);
|
||||||
|
|
||||||
$prepends = array(
|
$prepends = array(
|
||||||
@ -111,6 +134,12 @@ class ConfigStaticManifestTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIgnoreComments() {
|
||||||
|
$statics = $this->parseSelf()->getStatics();
|
||||||
|
$this->assertEquals(self::$commented_int, $statics[__CLASS__]['commented_int']['value']);
|
||||||
|
$this->assertEquals(self::$commented_string, $statics[__CLASS__]['commented_string']['value']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testIgnoresMethodStatics() {
|
public function testIgnoresMethodStatics() {
|
||||||
$statics = $this->parseSelf()->getStatics();
|
$statics = $this->parseSelf()->getStatics();
|
||||||
$this->assertNull(@$statics[__CLASS__]['method_static']);
|
$this->assertNull(@$statics[__CLASS__]['method_static']);
|
||||||
|
Loading…
Reference in New Issue
Block a user