-
Notifications
You must be signed in to change notification settings - Fork 493
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
Bleeding edge - Precise array shape for preg_replace_callback() $matches #3281
Conversation
This pull request has been marked as ready for review. |
Thank you. |
Could/should this be improved? https://phpstan.org/r/de0085e1-29c0-4346-849a-79948ec1c385 It's code from phpdoc-parser and copied from PHP-Parser I think, of course I don't understand it at all. |
Sounds feasible in theory to me, as you have a branch of the match group 1 which is "u", but that'd require a way to have partially static strings where you can look up index 0 and if index0 is known then we return it if not then it's just string or ''. That part you have to say if feasible. |
I don't understand the regex either but I hope I got you right: we would need dependent types, because |
Not dependent types, but something that is called tagged unions. Those are supported: https://phpstan.org/r/90cb0d94-b149-4b37-8c20-e5f7d984a160 Do you think the type here can be expressed like that? |
oh I see. I think we do similar things already in phpstan-src/src/Type/Php/RegexArrayShapeMatcher.php Lines 130 to 206 in 4755b37
I will have a look |
will do
preg_replace_callback_array
in a separate PR