-
Notifications
You must be signed in to change notification settings - Fork 464
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
Fix empty regex and empty alternation parse #3507
base: 1.12.x
Are you sure you want to change the base?
Conversation
b473d7f
to
bcd469c
Compare
bcd469c
to
d79f280
Compare
This pull request has been marked as ready for review. |
9f87f5a
to
4c61b1f
Compare
Do empty alternations or empty capturing groups have real world relevance? I don't think I have ever seen a regex using it..? |
They definitely do, |
@@ -104,13 +104,15 @@ public function dataValidate(): array | |||
'~Result of || is always true.~', | |||
[], | |||
false, | |||
true, | |||
false, |
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.
This is a blocker, I can't merge this. This is the main reason why IgnoredRegexValidator exists at all.
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.
@ondrejmirtes if I understand the test correctly it was rejecting ...||...
regex but the regex is valid, |
is an alternation regex token and thus ||
means alternation with empty string which is fixed by this PR, would you mind amending the test and pushing to by branch directly?
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.
IgnoredRegexValidator makes sure that if people have this in their configuration:
parameters:
ignoreErrors:
- '~Result of || is always true.~'
It makes PHPStan fail with the following error:
Invalid entry in ignoreErrors:
Ignored error ~Result of || is always true.~ has an unescaped '||' which leads to ignoring all errors. Use '\|\|' instead.
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.
Sure, but it MUST NOT fail, as it is valid regex :)
So please tell me how to make everyone happy.
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.
It's not a valid regex for ignoreErrors
.
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.
@ondrejmirtes can you please check and let me know if there is anything to address?
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.
@ondrejmirtes would you mind sharing your review?
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 in December, after I release 2.0. Don't expect it sooner.
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.
This is a bugfix into 1.12.x, might I understand why so late?
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.
Because I have different priorities and this is not a severe bug affecting a lot of users.
4c61b1f
to
7230e5d
Compare
84a8ecf
to
fa1f464
Compare
3c9c813
to
94ebfb5
Compare
94ebfb5
to
aec975a
Compare
fix phpstan/phpstan#11762