mirror of
https://github.com/danog/phpdoc-parser.git
synced 2025-01-22 22:01:36 +01:00
fix issues found by phpstan
This commit is contained in:
parent
0a3911f7a6
commit
aa22c2f688
@ -83,15 +83,16 @@ class Lexer
|
||||
|
||||
public function tokenize(string $s): array
|
||||
{
|
||||
if ($this->regexp === null) {
|
||||
if ($this->regexp === null || $this->types === null) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
assert($this->regexp !== null);
|
||||
assert($this->types !== null);
|
||||
|
||||
preg_match_all($this->regexp, $s, $tokens, PREG_SET_ORDER);
|
||||
|
||||
assert($this->types !== null);
|
||||
$count = count($this->types);
|
||||
|
||||
foreach ($tokens as &$match) {
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
if ($match[$i] !== null && $match[$i] !== '') {
|
||||
|
@ -31,9 +31,12 @@ class ParserException extends \Exception
|
||||
$this->currentOffset = $currentOffset;
|
||||
$this->expectedTokenType = $expectedTokenType;
|
||||
|
||||
$json = json_encode($currentTokenValue, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
assert($json !== false);
|
||||
|
||||
parent::__construct(sprintf(
|
||||
'Unexpected token %s, expected %s at offset %d',
|
||||
json_encode($currentTokenValue, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
$json,
|
||||
Lexer::TOKEN_LABELS[$expectedTokenType],
|
||||
$currentOffset
|
||||
));
|
||||
|
Loading…
x
Reference in New Issue
Block a user