diff --git a/src/AbstractLexer.php b/src/AbstractLexer.php index 7d33e41..3c87956 100644 --- a/src/AbstractLexer.php +++ b/src/AbstractLexer.php @@ -147,6 +147,8 @@ public function getInputUntilPosition($position) * @param T $type * * @return bool + * + * @psalm-assert-if-true !null $this->lookahead */ public function isNextToken($type) { @@ -159,6 +161,8 @@ public function isNextToken($type) * @param list $types * * @return bool + * + * @psalm-assert-if-true !null $this->lookahead */ public function isNextTokenAny(array $types) { @@ -169,6 +173,9 @@ public function isNextTokenAny(array $types) * Moves to the next token in the input string. * * @return bool + * + * @psalm-assert-if-true !null $this->lookahead + * @psalm-assert-if-false null $this->lookahead */ public function moveNext() { diff --git a/tests/AbstractLexerTest.php b/tests/AbstractLexerTest.php index 35ec673..bb3f955 100644 --- a/tests/AbstractLexerTest.php +++ b/tests/AbstractLexerTest.php @@ -219,19 +219,12 @@ public function testIsNextToken(string $input, array $expectedTokens): void */ public function testIsNextTokenAny(string $input, array $expectedTokens): void { - $allTokenTypes = array_map(static function ($token): string { - assert($token->type !== null); - - return $token->type; - }, $expectedTokens); - $this->concreteLexer->setInput($input); $this->concreteLexer->moveNext(); for ($i = 0; $i < count($expectedTokens); $i++) { assert($expectedTokens[$i]->type !== null); $this->assertTrue($this->concreteLexer->isNextTokenAny([$expectedTokens[$i]->type])); - $this->assertTrue($this->concreteLexer->isNextTokenAny($allTokenTypes)); $this->concreteLexer->moveNext(); } } @@ -296,7 +289,6 @@ public function testMarkerAnnotationLocaleTr(): void self::assertNull($mutableLexer->lookahead); self::assertTrue($mutableLexer->moveNext()); self::assertNull($mutableLexer->token); - self::assertNotNull($mutableLexer->lookahead); self::assertEquals('@', $mutableLexer->lookahead->value); self::assertTrue($mutableLexer->moveNext()); self::assertNotNull($mutableLexer->token);