-
Notifications
You must be signed in to change notification settings - Fork 548
more precise preg_match* return type signature #918
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
Conversation
| 'preg_grep' => ['array|false', 'regex'=>'string', 'input'=>'array', 'flags='=>'int'], | ||
| 'preg_last_error' => ['int'], | ||
| 'preg_match' => ['int|false', 'pattern'=>'string', 'subject'=>'string', '&w_subpatterns='=>'string[]', 'flags='=>'int', 'offset='=>'int'], | ||
| 'preg_match_all' => ['int|false|null', 'pattern'=>'string', 'subject'=>'string', '&w_subpatterns='=>'array', 'flags='=>'int', 'offset='=>'int'], |
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.
per https://www.php.net/preg_match_all null cannot be returned
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.
Someone somewhere persuaded me it can return null: 0d025e7
I'll merge this if you don't remove the null type.
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.
added back the null type
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.
In https://3v4l.org/DDBf3, I managed to make it return null on PHP 4.3
|
ohh sorry for renaming the PR title.. |
| 'preg_grep' => ['array|false', 'regex'=>'string', 'input'=>'array', 'flags='=>'int'], | ||
| 'preg_last_error' => ['int'], | ||
| 'preg_match' => ['int|false', 'pattern'=>'string', 'subject'=>'string', '&w_subpatterns='=>'string[]', 'flags='=>'int', 'offset='=>'int'], | ||
| 'preg_match_all' => ['int|false|null', 'pattern'=>'string', 'subject'=>'string', '&w_subpatterns='=>'array', 'flags='=>'int', 'offset='=>'int'], |
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.
Someone somewhere persuaded me it can return null: 0d025e7
I'll merge this if you don't remove the null type.
|
Thank you! |
|
Seems like this only works on PHP<8 for preg_match_all See https://phpstan.org/r/ba5ee68a-c998-4a7a-bb8b-6111f03a6d1a - php8 has int|false as return value |
|
arghs, seems I have forgotten to update the will look into it. |
|
Thanks, I can't find it in any of the delta files though, but maybe I missed something. |
|
yep, the point is that its missing from those delta files - I guess. |
|
fix in #1023 |
No description provided.