-
Notifications
You must be signed in to change notification settings - Fork 529
Support classes of literal strings in RegexGroupParser #3285
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
Conversation
This pull request has been marked as ready for review. |
btw: I think the issue-bot is confused, as the result seem to be reporting wrong assertion errors |
That's because the issue-bot already posted comments from 1.12.x where the preg array shapes do not require bleeding edge. Here we're still running on 1.11.x. |
Thank you! |
|
||
function (string $s): void { | ||
if (preg_match('/Price: (ba[rz])/i', $s, $matches)) { | ||
assertType("array{string, 'bar'|'baz'}", $matches); |
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
modifier must be honored, ie. 'baR'
must be present in the expected type
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.
At that point I'd fall back to not have literal strings at all. Too many combinations -> performance problems
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.
Yes, had the same thing in mind. Will fix.
Thanks
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.
fix in #3288
support literals within classes for constant type inference.
I do intentionally not support constant types for classes which define "from-to" ranges like
a-z
or0-9
, as the semantics can get complex easily and the list of constant chars explodes pretty fast.