-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add preg_last_error_msg() function #5185
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
Sounds reasonable. I'd suggest sending a mail to the internals mailing list about this. If the addition is not controversial, then we can add it without a full RFC. |
Thank you! I'll do that! |
Perhaps you didn't know, there's a wrapper library for regexps in PHP, and it already has |
@nikic Looks like there weren't any objections or concerns regarding this. Is there anything else I should do? |
Thank you, @nikic! Will this be part of PHP 8, or an earlier release? |
@nicoSWD This will be part of PHP 8.0. |
This PR was squashed before being merged into the 1.14-dev branch. Discussion ---------- [PHP 8.0] Add preg_last_error_msg function This PR adds the function `preg_last_error_msg` added in [php-src/pull/5185](php/php-src#5185) _Note_: I only tested the cases that don't require special `.ini` settings as I didn't want to set them dynamically in the test suite. Commits ------- 151806f [PHP 8.0] Add preg_last_error_msg function
This PR adds a new PCRE function called
preg_last_error_msg
which returns a human-friendly string representation of the last error.Seeing as most comments in the preg_last_error() documentation are about converting the error codes to meaningful messages, I see no reason why this shouldn't be supported natively.
The JSON extension also provides two separate functions for both use-cases.
And so do many others, such as
etc...
So to me it feels natural for this function to exist. The naming scheme seems faily inconsistent, but I like the
_msg
suffix the most.Thoughts? And does this need an RFC?
Edit:
For reference, here's the PHP internals discussion:
https://externals.io/message/108665