Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add psalm assertions #95

Merged
merged 1 commit into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@
<file name="src/AbstractLexer.php" />
</errorLevel>
</MixedAssignment>
<RedundantConditionGivenDocblockType>
<errorLevel type="suppress">
<!-- that test checks non-obvious things guaranteed by static analysis, just in case -->
<file name="tests/AbstractLexerTest.php" />
</errorLevel>
</RedundantConditionGivenDocblockType>
</issueHandlers>
</psalm>
7 changes: 7 additions & 0 deletions src/AbstractLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public function getInputUntilPosition($position)
* @param T $type
*
* @return bool
*
* @psalm-assert-if-true !null $this->lookahead
*/
public function isNextToken($type)
{
Expand All @@ -159,6 +161,8 @@ public function isNextToken($type)
* @param list<T> $types
*
* @return bool
*
* @psalm-assert-if-true !null $this->lookahead
*/
public function isNextTokenAny(array $types)
{
Expand All @@ -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()
{
Expand Down