Skip to content
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

preg_match_all with PREG_SET_ORDER does not see capture group as optional #11661

Closed
user16920 opened this issue Sep 9, 2024 · 2 comments
Closed

Comments

@user16920
Copy link

Bug report

The regex analyzer wrongly sees an optional capture group as always matching when it is followed by a required capture group

Code snippet that reproduces the problem

https://phpstan.org/r/8672bf06-a297-4186-bd3e-b0b21f3959e2

Expected output

I expect the resulting type to be array<int, array{string, ''|'ERR', non-empty-string}> as the first capturing group is optional. See https://3v4l.org/iaF0d for runtime results

Did PHPStan help you today? Did it make you happy in any way?

No response

@ondrejmirtes
Copy link
Member

Fixed phpstan/phpstan-src#3506

Copy link

github-actions bot commented Nov 7, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants