doctrine / lexer

Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
https://www.doctrine-project.org/projects/lexer.html
MIT License
11.05k stars 60 forks source link

Mark some methods as as impure for PHPStan #109

Closed greg0ire closed 1 year ago

greg0ire commented 1 year ago

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.