Hi

On 4/17/25 22:47, Paul M. Jones wrote:
As such, the _InvalidUriException_ would better extend from _LogicException_.

No. There is a de facto policy of “not using SPL exceptions in new code”. The replacement for LogicException is the Error hierarchy.

Also, as you quoted yourself, LogicException would be not appropriate to use as the base for InvalidUriException, since passing invalid URIs is not a programming error. The point of the URI classes is that they validate URIs, thus malformed inputs are expected in correctly written code.

See also https://github.com/php/php-src/pull/9220 for the rationale behind the exception hierarchy in ext/random (which is the first API that was rewritten for “modern PHP”). The choices there also served as the basis for the new ext/date hierarchy in PHP 8.3: https://wiki.php.net/rfc/datetime-exceptions

Best regards
Tim Düsterhus

Reply via email to