框架升级及修复升级后的bug
This commit is contained in:
+6
-4
@@ -51,11 +51,11 @@ class PhpToken implements \Stringable
|
||||
|
||||
public function getTokenName(): ?string
|
||||
{
|
||||
if ('UNKNOWN' === $name = token_name($this->id)) {
|
||||
$name = \strlen($this->text) > 1 || \ord($this->text) < 32 ? null : $this->text;
|
||||
if ($this->id < 256) {
|
||||
return \chr($this->id & 0xFF);
|
||||
}
|
||||
|
||||
return $name;
|
||||
return 'UNKNOWN' === ($name = token_name($this->id)) ? null : $name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,13 +92,15 @@ class PhpToken implements \Stringable
|
||||
$tokens = token_get_all($code, $flags);
|
||||
foreach ($tokens as $index => $token) {
|
||||
if (\is_string($token)) {
|
||||
$id = \ord($token);
|
||||
// b" is the only such token longer than one char
|
||||
$id = \ord($token[-1]);
|
||||
$text = $token;
|
||||
} else {
|
||||
[$id, $text, $line] = $token;
|
||||
}
|
||||
$tokens[$index] = new static($id, $text, $line, $position);
|
||||
$position += \strlen($text);
|
||||
$line += preg_match_all('/\r\n?|\n/', $text);
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
|
||||
Reference in New Issue
Block a user