€0.00 — free as in speechtonight's forecast: clear skies over production Cache: warm · Deploys: fair, 0% rollbacks expectedset by moonlight, shipped before dawn · deploy freely Page A2

The Daily Commit The Nightly Build

Dev news, typeset daily — PHP · AI · The Wider Stack

The developer's evening paper — PHP · AI · The Wider Stack

Wednesday, September 9, 2026 Vol. I — No. 511 · Morning editionLate edition EN DE FR ES

PHP · RFC Watch

Vote Opens on PREG_THROW_ON_ERROR Flag for preg_* Functions

Voting has started on a PHP RFC that adds an opt-in PREG_THROW_ON_ERROR flag for preg_* functions.

curated by Georg

With the flag, PCRE errors surface as a \PregException instead of requiring preg_last_error() checks. The vote closes on 2026-09-18, with Tim Düsterhus among the early opponents.

The voting phase for the PREG_THROW_ON_ERROR RFC has begun, announced by author Osama Aldemeery on the PHP internals list after a discussion period without open issues. Voting closes on 2026-09-18 at 17:00 UTC. The RFC lives at wiki.php.net/rfc/preg_throw_on_error, and the implementation is in php-src pull request 22797.

The proposal adds an opt-in PREG_THROW_ON_ERROR flag. Passing it to any preg_* matching function makes every PCRE error recorded by the call additionally throw a \PregException. The exception's code and message match preg_last_error() and preg_last_error_msg() exactly. Calls without the flag behave exactly as they do today.

Tim Düsterhus voted against the RFC while agreeing with the general concept. He objects to keeping a Warning on compilation errors: since the feature is new and opt-in, he argues there are no backwards compatibility constraints, and the requirement that $e->getMessage() equal preg_last_error_msg() weakens the feature because the exception should carry all necessary information.

He also disagrees with leaving exceptions thrown inside user callbacks unwrapped. In his view they should become a \PregException with the original exception set as $previous. Otherwise developers still need a catch(Exception) around every preg_ call, which undermines the point of a dedicated exception class. He notes this also conflicts with the PHP throwable policy, which requires extensions to wrap exceptions from external functionality and set $previous.

Read the original source ↗

Rate this article: 0

Readers’ Forum

No contributions yet — open the debate.

The Daily CommitThe Nightly Build — Page A1