Fix empty regex and empty alternation parse#3507
Fix empty regex and empty alternation parse#3507ondrejmirtes merged 8 commits intophpstan:1.12.xfrom
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, |
There was a problem hiding this comment.
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.
@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.
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.
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.
It's not a valid regex for ignoreErrors.
There was a problem hiding this comment.
Maybe in December, after I release 2.0. Don't expect it sooner.
There was a problem hiding this comment.
This is a bugfix into 1.12.x, might I understand why so late?
There was a problem hiding this comment.
Because I have different priorities and this is not a severe bug affecting a lot of users.
There was a problem hiding this comment.
@ondrejmirtes is now a better time?
About the usecase, see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.65.0/src/DocBlock/TypeExpression.php#L62 for example.
(a|b|) is shorter syntax of ((?:a|b|)?), the first one is currently now parsed by PHPStan and this PR fixes it.
There was a problem hiding this comment.
Hi @ondrejmirtes, please review, the feedback was addressed.
4c61b1f to
7230e5d
Compare
84a8ecf to
fa1f464
Compare
3c9c813 to
94ebfb5
Compare
94ebfb5 to
aec975a
Compare
aec975a to
efc81bc
Compare
efc81bc to
f40aae6
Compare
|
This pull request has been marked as ready for review. |
|
Looks fine, thank you. |
|
Thank you ❤ |
fix phpstan/phpstan#11762