mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
This commit is contained in:
parent
4bf601ec1f
commit
27cea80b15
@ -242,6 +242,19 @@ class SS_ConfigStaticManifest_Parser {
|
|||||||
$type = is_array($token) ? $token[0] : $token;
|
$type = is_array($token) ? $token[0] : $token;
|
||||||
|
|
||||||
if($type == T_CLASS) {
|
if($type == T_CLASS) {
|
||||||
|
// Fetch the last token
|
||||||
|
$pos = $this->pos - 1; // Subtract 1 as the pointer is always 1 place ahead of the current token
|
||||||
|
do {
|
||||||
|
$pos--;
|
||||||
|
$prev = $this->tokens[$pos];
|
||||||
|
} while ($pos > 0 && is_array($prev) && $prev[0] == T_WHITESPACE);
|
||||||
|
|
||||||
|
// Ignore class keyword if it's being used for class name resolution: ClassName::class
|
||||||
|
$lastType = ($prev === (array)$prev) ? $prev[0] : $prev;
|
||||||
|
if ($lastType === T_PAAMAYIM_NEKUDOTAYIM) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$next = $this->nextString();
|
$next = $this->nextString();
|
||||||
if($next === null) {
|
if($next === null) {
|
||||||
user_error("Couldn\'t parse {$this->path} when building config static manifest", E_USER_ERROR);
|
user_error("Couldn\'t parse {$this->path} when building config static manifest", E_USER_ERROR);
|
||||||
|
@ -257,6 +257,16 @@ DOC;
|
|||||||
|
|
||||||
$this->assertEquals($expected, $statics[':ss:test2']);
|
$this->assertEquals($expected, $statics[':ss:test2']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParsingClassKeyword() {
|
||||||
|
$parser = new SS_ConfigStaticManifest_Parser(__DIR__ .
|
||||||
|
'/ConfigStaticManifestTest/ConfigStaticManifestTestClassKeyword.php');
|
||||||
|
$parser->parse();
|
||||||
|
|
||||||
|
$statics = $parser->getStatics();
|
||||||
|
|
||||||
|
$this->assertEquals('bar', $statics['ConfigStaticManifestTestClassKeyword']['foo']['value']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigStaticManifestTest_Parser extends SS_ConfigStaticManifest_Parser implements TestOnly {
|
class ConfigStaticManifestTest_Parser extends SS_ConfigStaticManifest_Parser implements TestOnly {
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ConfigStaticManifestTestClassKeyword implements TestOnly {
|
||||||
|
|
||||||
|
private static $foo = 'bar';
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->inst = Injector::inst()->get(static::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user