Exception for invalid characters in number base functions
Voting; not accepted. The vote opened on 16 October 2026. The author's voting thread went out at about 07:41 UTC, and the RFC page (version 0.3, dated 2026-08-11, last modified 2026-10-16 at 08:13 UTC) changed its status to Voting. The official RFC index also lists it as voting. There is one question: "Throw a Exception for invalid characters in number base conversion functions?" It is the primary vote, needs a 2/3 majority and closes on 2026-11-01 at 15:30 UTC. When the page was read at about 10:05 UTC on 16 October, the interim count was 3 yes, 0 no, 0 abstain. This is an interim count, not a result. On 21 October at about 16:05 UTC the page listed 22 voters with an interim count of 21 yes, 1 no, 0 abstain, still not a result. On 22 October at about 10:05 UTC (page still last modified 2026-10-16 08:13 UTC) it listed 23 voters with an interim count of 22 yes, 1 no, 0 abstain, again not a result. On 23 October at about 22:05 UTC (page still last modified 2026-10-16 08:13 UTC) the interim count was 23 yes, 1 no, 0 abstain (24 voters), still not a result. On 25 October at about 17:05 UTC (page still last modified 2026-10-16 08:13 UTC) it was 24 yes, 1 no, 0 abstain (25 voters), again not a result. It was unchanged at about 05:05 UTC on 27 October. The proposed version is PHP 8.7. The vote opened on the date the author announced on 9 October.
Proposal
bindec(), octdec(), hexdec() and base_convert() would throw when the input contains a
character that is not valid in the given base. Today they ignore such characters and emit
E_DEPRECATED ("Invalid characters passed for attempted conversion, these have been ignored"),
so hexdec('z') returns int(0). For base_convert() validity depends on the source base:
'f' is accepted in base 16 but would throw in base 15.
Version 0.3 changed the exception from ValueError to a plain Exception. The page argues that
ValueError implies a bug in the program, which bad input is not necessarily. More specific
exceptions are listed as rejected for now: the SPL exceptions belong to another extension, and
ext/standard has no suitable exception of its own. The voting thread uses the new "Throw exception" title.
Until 22 October the official index still used the older "Throw ValueError" title. The index collected at 10:01 UTC
on 22 October uses "Throw exception for invalid characters in number base functions", matching the page.
Background and affected versions
The Base Convert Improvements RFC,
implemented in PHP 7.4, added the deprecation notice and named an exception in a later version as
the next step. That step never happened. Since PHP 7.4 invalid characters are ignored with a
deprecation notice; the RFC's example lists this behavior for PHP 7.4 through 8.6. The RFC expects separator
characters such as hexdec('1234-5678') to be the main legitimate use broken by the change.
base64_decode(), intval() and other functions are out of scope.
Evidence and limitations
- The implementation is php-src PR #22365, opened on
19 June 2026. GitHub labels it "ABI break". Its description says it changes the behavior to an
Exception, but its first commit message still saysValueError. Whether it is merged or matches version 0.3 was not checked. - An earlier internals message (132379) also said a vote would open the following Friday, and called the RFC "not really controversial". The fetched text has no date. No vote followed that message. The vote opened only after the 9 October announcement.
- Until 16 October the page's vote block showed "Final result: 0 0 0" and "This poll has been closed". That was the unopened widget, not a ballot result. The poll has been open since 16 October.
Objection to the plain Exception (21 October)
On 21 October a voter replied in the voting thread that they had voted no
solely because of the generic \Exception, which callers can only catch together with every other exception. They
pointed out that the Base Convert Improvements RFC had named InvalidArgumentException as the intended PHP 8 step,
and asked for the SPL restriction to be resolved or a dedicated exception class introduced. The author answered that
a more specific exception is desirable but not easy to get right now, that throwing Exception now makes it possible to
change to something more specific later, and that InvalidArgumentException is wrong because it signals a type error and extends
LogicException (a programming error), whereas bad input need not be one.
news-web.php.net returned HTTP 502 for the individual messages, so they were read on the externals.io mirror.
Related: Filter enums, another PHP 8.7 proposal about handling invalid input.