-
-
Notifications
You must be signed in to change notification settings - Fork 914
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
Regex matches should have array shape if the regex is known #9502
Comments
PHPStan already contains a regex AST parser, which could be used for a even more precise typing |
As a first easy step shouldn't we remove the FALSE return type from Do you have in mind
? |
The returned value can still be false even if the regex is valid. This has definitely been discussed somewhere on the issue tracker. There might even have been a PR. |
Removing false was discussed in the past in some issue somewhere. A valid regex is not the only case where false is returned |
|
Sorry, I looked for multiple issues and tried to find the discussion but didn't find it before asking it. Thanks for the quick answer ! |
@ondrejmirtes this issue can be closed |
Thanks |
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. |
Feature request
If the regex is known/constant a very little trick is needed to obtain the returned array keys/shape: https://3v4l.org/sOXbn
Regexes are everywhere and thus the result shape would improve phpstan checks a lot.
https://phpstan.org/r/71ffe793-4349-4555-8385-a233d152178d
The text was updated successfully, but these errors were encountered: