-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Extract token array shape into a Psalm type #64
Conversation
c706a7d
to
bf4c020
Compare
@@ -160,7 +162,7 @@ public function isNextToken($token) | |||
/** | |||
* Checks whether any of the given tokens matches the current lookahead. | |||
* | |||
* @param string[] $tokens | |||
* @param list<int|string|null> $tokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it makes sense to allow null
here, but I'm forced to do so if a token type can be passed here. Either this is correct or there should be a subtype of Token
that disallows null
. Maybe we should also rename $tokens
to $tokenTypes
to make things less confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking a bit more into the code, I think the type will be null if it is not understood by the lexer (no condition in getType
matches the value). I don't think it makes sense to check if that's the case, so let me create another type just for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should also rename $tokens to $tokenTypes to make things less confusing.
skipUntil
uses $type
, so let's be consistent with that.
76f3e06
to
50de489
Compare
This should make things less error prone and easier on the eyes.
This should make things less error prone and easier on the eyes.