protected static eatFirstKey ( string $input ) : array | ||
$input | string | The input to consume |
Résultat | array | The collected string and any remaining content, followed by a boolean indicating whether this is a class name. |
protected static function eatFirstKey($input)
{
$length = strlen($input);
$collected = '';
$isClassName = false;
if ($input[0] === '"') {
$result = self::eatString(substr($input, 1));
return [$result[0], substr($result[1], 1)];
}
for ($i = 0; $i < $length; $i++) {
$c = $input[$i];
if ($c === '@') {
$isClassName = true;
break;
} elseif ($c === ':') {
break;
} else {
$collected .= $c;
}
}
return [$collected, substr($input, $i + 1), $isClassName];
}