Skip to content

Commit a53da19

Browse files
committed
Remove unnecessary temp array
1 parent 68d1072 commit a53da19

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 8
2+
level: 9
33
paths:
44
- src
55
- tests

src/ParserAbstract.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ protected function doParse(): Program
279279
if ($rule === 0) {
280280
/* accept */
281281
//$this->traceAccept();
282+
/** @phpstan-ignore return.type */
282283
return $this->semValue;
283284
}
284285
if ($rule !== $this->unexpectedTokenRule) {
@@ -444,21 +445,21 @@ protected function createTokenMap(): array
444445
if ($name === 'EOF' || $name === 'error') {
445446
continue;
446447
}
447-
$tokenMap[$name] = constant(static::class . '::' . $name);
448-
}
448+
$extSymbol = constant(static::class . '::' . $name);
449+
450+
if (!is_int($extSymbol)) {
451+
$type = get_debug_type($extSymbol);
452+
throw new \Exception("Unexpected external ID type $type for token $name");
453+
}
449454

450-
// We have created a map from token IDs to external symbol IDs.
451-
// Now map them to the internal symbol ID.
452-
$fullTokenMap = [];
453-
foreach ($tokenMap as $token => $extSymbol) {
454455
$intSymbol = $this->tokenToSymbol[$extSymbol];
455456
if ($intSymbol === $this->invalidSymbol) {
456457
continue;
457458
}
458-
$fullTokenMap[$token] = $intSymbol;
459+
$tokenMap[$name] = $intSymbol;
459460
}
460461

461-
return $fullTokenMap;
462+
return $tokenMap;
462463
}
463464

464465
/*

0 commit comments

Comments
 (0)