Skip to content

Commit ba2f368

Browse files
committed
Mark some methods as as impure for PHPStan
By default, PHPSTan considers assumes that all methods that return a value are pure, meaning they have no side effects. While we could configure PHPStan so it is consistent with Psalm, we do not know how downstream projects are configured and should assume they rely on the default behavior. See https://phpstan.org/blog/remembering-and-forgetting-returned-values Both moveNext() and glimpse() have side effects in that they modify properties, and are therefore marked as impure.
1 parent 84a527d commit ba2f368

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/AbstractLexer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public function isNextTokenAny(array $types)
164164
*
165165
* @return bool
166166
*
167+
* @phpstan-impure
167168
* @psalm-assert-if-true !null $this->lookahead
168169
*/
169170
public function moveNext()
@@ -220,6 +221,8 @@ public function peek()
220221
*
221222
* @return mixed[]|null The next token or NULL if there are no more tokens ahead.
222223
* @psalm-return Token<T, V>|null
224+
*
225+
* @phpstan-impure
223226
*/
224227
public function glimpse()
225228
{

0 commit comments

Comments
 (0)