Skip to content

Commit

Permalink
Merge pull request #95 from greg0ire/add-asserts
Browse files Browse the repository at this point in the history
Add psalm assertions
  • Loading branch information
greg0ire authored Dec 11, 2022
2 parents 3cf140b + ab64387 commit 8275278
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit 8275278

Please sign in to comment.