A pre-RFC proposal to the PHP internals mailing list suggests adding a `PREG_THROW_ON_ERROR` flag to all `preg_*()` functions. Currently, PCRE errors in PHP either emit a warning and return `false`, or silently fail and require a follow-up `preg_last_error()` call to detect. The proposed flag would make any PCRE failure throw a `Pcre\PcreException` carrying the error code and message, consistent with how `JSON_THROW_ON_ERROR` and `FILTER_THROW_ON_FAILURE` work for their respective extensions. The author has completed a full implementation and is seeking community interest and feedback on two design questions: whether to throw on the first failing array element, and whether `_ON_ERROR` or `_ON_FAILURE` is the better naming convention.

4m read timeFrom externals.io
Post cover image
171 Impressions