Re: [RFC][DISCUSSION] Add RFC 4648 compliant data encoding API

From: Date: Mon, 14 Jul 2025 21:26:36 +0000
Subject: Re: [RFC][DISCUSSION] Add RFC 4648 compliant data encoding API
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-128043@lists.php.net to get a copy of this message
Hi all, I have a few suggestions, starting with naming improvements: - Forgiving instead of Lenient (align with https://infra.spec.whatwg.org/#forgiving-base64) - Shorten the option names; one example would be Variable/Constant instead of Unprotected/ConstantTime, but I think most could be rethinked - $input or $data instead of $decoded (could actually do the same instead of $encoded, but that one doesn't feel as wrong) - Not strictly about naming, but it similarly feels wrong that UnableToDecodeException extends EncodingException (which seems to have no purpose) However, I'm not a fan of how these simple functions have so many option flags ... it feels forced, trying to accomodate too much at once. I'd rather have discrete functions, like base64_*() and base64url_*() - I chose this example because base64 and base64url also have arguably different desirable defaults for padding; almost all pad-stripping I've seen in the wild has been for the purposes of converting to base64url. On a semi-related note, I'm not sure if including the IMAP variant isn't complicating things for no good reason (it is extra-niche, and we have imap_binary/base64() already). Also, the RFC doesn't specify whether DecodingMode::Strict would cause an error in case of missing padding? That being said, I'm very glad to see this! Cheers, Andrey.

« previous php.internals (#128043) next »