mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Minor refactor of SS_ConfigStaticManifest_Parser::parse() (#5782)
This commit is contained in:
parent
8a21d53a07
commit
21cf67f1b4
@ -198,6 +198,25 @@ class SS_ConfigStaticManifest_Parser {
|
|||||||
return $next;
|
return $next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the previous token processed. Does *not* decrement the pointer
|
||||||
|
*
|
||||||
|
* @param bool $ignoreWhitespace - if true will skip any whitespace tokens & only return non-whitespace ones
|
||||||
|
* @return null | mixed - Either the previous token or null if there isn't one
|
||||||
|
*/
|
||||||
|
protected function lastToken($ignoreWhitespace = true) {
|
||||||
|
// Subtract 1 as the pointer is always 1 place ahead of the current token
|
||||||
|
$pos = $this->pos - 1;
|
||||||
|
do {
|
||||||
|
if($pos <= 0) return null;
|
||||||
|
$pos--;
|
||||||
|
$prev = $this->tokens[$pos];
|
||||||
|
}
|
||||||
|
while($ignoreWhitespace && is_array($prev) && $prev[0] == T_WHITESPACE);
|
||||||
|
|
||||||
|
return $prev;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next set of tokens that form a string to process,
|
* Get the next set of tokens that form a string to process,
|
||||||
* incrementing the pointer
|
* incrementing the pointer
|
||||||
@ -242,15 +261,10 @@ class SS_ConfigStaticManifest_Parser {
|
|||||||
$type = ($token === (array)$token) ? $token[0] : $token;
|
$type = ($token === (array)$token) ? $token[0] : $token;
|
||||||
|
|
||||||
if($type == T_CLASS) {
|
if($type == T_CLASS) {
|
||||||
// Fetch the last token
|
$lastToken = $this->lastToken();
|
||||||
$pos = $this->pos - 1; // Subtract 1 as the pointer is always 1 place ahead of the current token
|
$lastType = ($lastToken === (array)$lastToken) ? $lastToken[0] : $lastToken;
|
||||||
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
|
// 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) {
|
if ($lastType === T_PAAMAYIM_NEKUDOTAYIM) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user