Re: [RFC][Discussion] Grapheme Mask
| From: | Ayesh Karunaratne | Date: | Sun, 28 Jun 2026 09:59:50 +0000 |
| Subject: | Re: [RFC][Discussion] Grapheme Mask | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131554@lists.php.net to get a copy of this message | ||
> I’d like to start the discussion period for the Grapheme Mask RFC:
>
> https://wiki.php.net/rfc/grapheme_mask
>
> The RFC proposes
grapheme_mask() for the Intl extension, with
> Unicode-aware masking based on grapheme cluster boundaries.
>
Hi Sepehr,
Thank you for the work put into the RFC.
**Opinion**: I agree that Grapheme is the right place for this
function, but a str_* function would have improved its "natural
discovery." Perhaps adding a str_mask in addition to the
grapheme_mask makes more sense?
**Suggestion**: I find the limitations of $start and $length too
restrictive. Laravel's Str::mask[^1] for example offers more
expressive control over the offset and length. Two of the more common
string masking callsites are when you mask an email address while
revealing the domain name and 1-2 characters of the username part, or
showing only the last four characters of a payment card number.
Because different use cases require different masking patterns, I
think the proposed grapheme_mask function will not be an easy
drop-in replacement. However, I think providing a built-in masking
function in the language is a good move, not an unnecessary feature.
[^1]: https://laravel.com/docs/13.x/strings#method-str-mask