Hi everyone,
I'm officially starting my work on the ext/intl and standard string
functions, and I'm very excited to share my first major proposal for PHP
8.7!
I have successfully set up my local development environment and compiler on
my machine, and everything is up and running smoothly.
As part of this, I would like to propose a new native function called
str_mask().
Proposal Overview
The str_mask() function is designed to securely mask portions of a string
using a specified mask character. This is extremely useful for handling
sensitive user data like credit card numbers, phone numbers, and tokens.
Signature:
str_mask(string $string, string $mask_char = '*', int $offset = 0, ?int
$length = null): string
Examples
-
Masking a credit card (positive offset & length):
$credit_card = '1234567890123456';
$masked_card = str_mask($credit_card, '*', 4, 8);
// Output: 1234********3456 -
Masking a phone number (negative offset to count from the end):
$phone_number = '+989123456789';
$masked_phone = str_mask($phone_number, 'X', -4);
// Output: +9891234XXXX
You can find all the details, implementation plans, and RFC discussions
here:
https://wiki.php.net/rfc/str_mask
Looking forward to hearing your feedback and thoughts!
Best regards,
Sepehr Mahmoudi
Hi Sepehr,
I have a few concerns with the current semantics before this becomes
another permanent global API.
The RFC motivates str_mask() primarily around sensitive data and privacy,
but the proposed behavior is fail-open:
str_mask('AB', '*', 3) === 'AB'
An incorrect offset therefore returns the original sensitive value
unchanged.
If masking is being presented as the reason for introducing the function,
why is an invalid masking range considered successful rather than
exceptional? Silently leaking the input seems like a particularly
surprising contract for an API whose stated purpose is hiding data.
There is a similar issue with $mask_char.
The signature accepts string, but the RFC specifies that only the first
byte is used. So:
str_mask($value, '●', ...)
does not mask using the character that was passed. It takes one byte from a
multibyte UTF-8 sequence and can produce invalid UTF-8.
I understand that str_mask() is intended to be byte-oriented, but then
accepting an arbitrary string and silently truncating it to one byte feels
like the wrong API. Why not require exactly one byte and throw ValueError
otherwise?
My larger concern, though, is whether the primitive itself earns a place in
core.
The RFC's email example still needs strpos() and strlen() to determine
where the semantic part to hide actually is. Credit cards, emails, phone
numbers, tokens and identifiers all have different disclosure rules. PHP
cannot determine those rules; the caller still has to do that work.
Once the caller already knows the offset and length, the remaining
operation is essentially replacement of a substring with a repeated byte.
So I think there are three questions that need stronger answers:
-
What recurring capability does str_mask() provide that cannot already be
expressed clearly with existing string primitives? -
Do we have evidence from real-world codebases that this pattern occurs
frequently enough to justify another global function rather than a small
userland abstraction? -
The RFC states that the implementation is "significantly faster". Could
you include reproducible benchmarks against an equivalent
substr_replace()/str_repeat() implementation, including short strings
representative of the examples in the RFC?
For operations on strings this small, C being faster in isolation does not
necessarily establish that the difference is meaningful enough to justify
expanding the standard library.
I would also avoid describing this as providing privacy or GDPR compliance.
Whether exposing part of an identifier is appropriate is contextual, and a
generic byte-level replacement operation cannot provide that guarantee.
I think these questions should be resolved before discussing the
implementation itself.
Best regards,
Pratik Bhujel
در تاریخ جمعه ۱۸ سپتامبر ۲۰۲۶، ۲۲:۲۳ Pratik Bhujel <
prateekbhujelpb@gmail.com> نوشت:
Hi Sepehr,
I have a few concerns with the current semantics before this becomes
another permanent global API.The RFC motivates str_mask() primarily around sensitive data and privacy,
but the proposed behavior is fail-open:str_mask('AB', '*', 3) === 'AB'An incorrect offset therefore returns the original sensitive value
unchanged.If masking is being presented as the reason for introducing the function,
why is an invalid masking range considered successful rather than
exceptional? Silently leaking the input seems like a particularly
surprising contract for an API whose stated purpose is hiding data.There is a similar issue with $mask_char.
The signature accepts string, but the RFC specifies that only the first
byte is used. So:str_mask($value, '●', ...)does not mask using the character that was passed. It takes one byte from
a multibyte UTF-8 sequence and can produce invalid UTF-8.I understand that str_mask() is intended to be byte-oriented, but then
accepting an arbitrary string and silently truncating it to one byte feels
like the wrong API. Why not require exactly one byte and throw ValueError
otherwise?My larger concern, though, is whether the primitive itself earns a place
in core.The RFC's email example still needs
strpos()andstrlen()to determine
where the semantic part to hide actually is. Credit cards, emails, phone
numbers, tokens and identifiers all have different disclosure rules. PHP
cannot determine those rules; the caller still has to do that work.Once the caller already knows the offset and length, the remaining
operation is essentially replacement of a substring with a repeated byte.So I think there are three questions that need stronger answers:
What recurring capability does str_mask() provide that cannot already
be expressed clearly with existing string primitives?Do we have evidence from real-world codebases that this pattern occurs
frequently enough to justify another global function rather than a small
userland abstraction?The RFC states that the implementation is "significantly faster". Could
you include reproducible benchmarks against an equivalent
substr_replace()/str_repeat() implementation, including short strings
representative of the examples in the RFC?For operations on strings this small, C being faster in isolation does not
necessarily establish that the difference is meaningful enough to justify
expanding the standard library.I would also avoid describing this as providing privacy or GDPR
compliance. Whether exposing part of an identifier is appropriate is
contextual, and a generic byte-level replacement operation cannot provide
that guarantee.I think these questions should be resolved before discussing the
implementation itself.Best regards,
Pratik Bhujel
Hi Pratik,
Thanks for the feedback! I've updated the RFC document to reflect the
fail-closed error handling design and edge-case behavior we discussed.
Regarding grapheme_mask(), I haven't designed or implemented it yet, but
I will definitely incorporate these principles once I start working on it
in ext/intl.
Also, to ensure this on it in ext/intl.
Also, to ensure this to include real-world usage analysis/benchmarks (e.g.
log masking, sensitive data display in popular frameworks) in the proposal?
I'd love to hear your thoughts on this or any specific cases you have in
mind.
Best regards,
Sepehr
On Fri, Sep 18, 2026 at 9:27 PM سپهر محمودی sepehrphpr@gmail.com wrote:
Hi everyone,
I'm officially starting my work on the ext/intl and standard string functions, and I'm very excited to share my first major proposal for PHP 8.7!
I have successfully set up my local development environment and compiler on my machine, and everything is up and running smoothly.
As part of this, I would like to propose a new native function called str_mask().
Proposal Overview
The str_mask() function is designed to securely mask portions of a string using a specified mask character. This is extremely useful for handling sensitive user data like credit card numbers, phone numbers, and tokens.
Signature:
str_mask(string $string, string $mask_char = '*', int $offset = 0, ?int $length = null): stringExamples
Masking a credit card (positive offset & length):
$credit_card = '1234567890123456';
$masked_card = str_mask($credit_card, '*', 4, 8);
// Output: 1234********3456Masking a phone number (negative offset to count from the end):
$phone_number = '+989123456789';
$masked_phone = str_mask($phone_number, 'X', -4);
// Output: +9891234XXXXYou can find all the details, implementation plans, and RFC discussions here:
https://wiki.php.net/rfc/str_maskLooking forward to hearing your feedback and thoughts!
Best regards,
Sepehr Mahmoudi
Hi,
Unless I am missing something...this looks identical to the existing
substr_replace. It has the same signature with just a different name
and without array being part of the params/return types.
Your examples could be rewritten as:
$credit_card = '1234567890123456';
$masked_card = substr_replace($credit_card, str_repeat('*', 8), 4, 8);
$phone_number = '+989123456789';
$masked_phone = substr_replace($phone_number, str_repeat('X', 4), -4);
Regards,
Osama
در تاریخ جمعه ۱۸ سپتامبر ۲۰۲۶، ۲۳:۱۲ Osama Aldemeery aldemeery@gmail.com
نوشت:
On Fri, Sep 18, 2026 at 9:27 PM سپهر محمودی sepehrphpr@gmail.com
wrote:Hi everyone,
I'm officially starting my work on the ext/intl and standard string
functions, and I'm very excited to share my first major proposal for PHP
8.7!I have successfully set up my local development environment and compiler
on my machine, and everything is up and running smoothly.As part of this, I would like to propose a new native function called
str_mask().Proposal Overview
The str_mask() function is designed to securely mask portions of a
string using a specified mask character. This is extremely useful for
handling sensitive user data like credit card numbers, phone numbers, and
tokens.Signature:
str_mask(string $string, string $mask_char = '*', int $offset = 0, ?int
$length = null): stringExamples
Masking a credit card (positive offset & length):
$credit_card = '1234567890123456';
$masked_card = str_mask($credit_card, '*', 4, 8);
// Output: 1234********3456Masking a phone number (negative offset to count from the end):
$phone_number = '+989123456789';
$masked_phone = str_mask($phone_number, 'X', -4);
// Output: +9891234XXXXYou can find all the details, implementation plans, and RFC discussions
here:
https://wiki.php.net/rfc/str_maskLooking forward to hearing your feedback and thoughts!
Best regards,
Sepehr MahmoudiHi,
Unless I am missing something...this looks identical to the existing
substr_replace. It has the same signature with just a different name
and withoutarraybeing part of the params/return types.Your examples could be rewritten as:
$credit_card = '1234567890123456'; $masked_card = substr_replace($credit_card, str_repeat('*', 8), 4, 8); $phone_number = '+989123456789'; $masked_phone = substr_replace($phone_number, str_repeat('X', 4), -4);Regards,
Osama
Hi Osama,
Thank you for the feedback!
While it is true that masking can be composed using substr_replace($str, str_repeat($mask, $len), $offset, $len), there are three key motivations
behind proposing str_mask():
-
Ergonomics & Clarity: Masking sensitive information (PII, credit cards,
emails, tokens) is one of the most common everyday tasks in modern web
security and logging. Writingsubstr_replace(..., str_repeat(...), ...)
is verbose and prone to off-by-one errors. A dedicated function makes the
intent clear. -
Fail-Closed Security & Strict Validation: Data masking often deals with
sensitive credentials.substr_replace()has legacy and lenient behaviors
regarding out-of-bounds offsets. In contrast,str_mask()is designed with
a strict fail-closed approach (throwingValueErroron invalid boundaries
or empty mask characters) to ensure sensitive data is never silently
exposed due to silent clipping. -
Performance & Memory: The
substr_replace + str_repeatcombination
performs two separate string allocations (one temporary string created by
str_repeatand the final string created bysubstr_replace).
str_mask()computes the masked string directly in C in a single
allocation pass, making it more memory- and CPU-efficient.
Best regards,
Sepehr
Hi,
> 1. Ergonomics & Clarity: Masking sensitive information (PII, credit cards, emails, tokens) is one of the most common everyday tasks in modern web security and logging. Writing substr_replace(..., str_repeat(...), ...) is verbose and prone to off-by-one errors. A dedicated function makes the intent clear.
I don't think it is verbose. Perhaps different people have different coding styles. But I down vote on that statement.
> 2. Fail-Closed Security & Strict Validation: Data masking often deals with sensitive credentials. substr_replace() has legacy and lenient behaviors regarding out-of-bounds offsets. In contrast, str_mask() is designed with a strict fail-closed approach (throwing ValueError on invalid boundaries or empty mask characters) to ensure sensitive data is never silently exposed due to silent clipping.
Can you provide an actual example of out-of-bounds offsets and it's impact for us to understand?
> 3. Performance & Memory: The substr_replace + str_repeat combination performs two separate string allocations (one temporary string created by str_repeat and the final string created by substr_replace). str_mask() computes the masked string directly in C in a single allocation pass, making it more memory- and CPU-efficient.
Well, I'd argue that the str_repeat here is basically for better readability. That
$phone_number = '+989123456789';
$masked_phone = substr_replace($phone_number, str_repeat('X', 4), -4);
Can be written to
$phone_number = '+989123456789';
$masked_phone = substr_replace($phone_number, 'XXXX', -4);
So there is only one single allocation. The second one you are pointing to comes from repeating the string, which is not what we are arguing about here.
Cheers,
Weilin Du
8On Fri, Sep 18, 2026, at 20:26, سپهر محمودی wrote:
As part of this, I would like to propose a new native function called str_mask().
Not useful.
Easily implemented in user-space.
Performance would never be an issue for a function typically used on small strings a few times per request.
In the multi-million-line web application I work on this probably would not be used even once.
Please stop this. Your mails read like AI slop, and your proposals are of very poor quality. I suspect that there are more than a few thousand humans reading this list, and you are wasting their time.
Please don't see this as a personal attack. It's the work that is not good enough, not you as a person.
Greetings, Casper
Not useful.
Easily implemented in user-space.
Performance would never be an issue for a function typically used on small strings a few times per request.In the multi-million-line web application I work on this probably would not be used even once.
Greetings, Casper
This. I don’t see any reason why this should added. Its use-case is quite a niche, which can be easily solved by calling substr_replace together with str_repeat.
If you want to go on with your idea, the string parameter of this function should have the SensitiveParameter attribute or else it may end up in a backtrace.
Regards,
Jordi
در تاریخ شنبه ۱۹ سپتامبر ۲۰۲۶، ۰۶:۴۸ Jordi Kroon jordikroon@me.com نوشت:
On 18 Sep 2026 at 18:43 -0400, Casper Langemeijer langemeijer@php.net,
wrote:Not useful.
Easily implemented in user-space.
Performance would never be an issue for a function typically used on small
strings a few times per request.In the multi-million-line web application I work on this probably would
not be used even once.Greetings, Casper
This. I don’t see any reason why this should added. Its use-case is quite
a niche, which can be easily solved by calling substr_replace together with
str_repeat.If you want to go on with your idea, the string parameter of this function
should have the SensitiveParameter attribute or else it may end up in a
backtrace.Regards,
Jordi
Hi Jordi,
Thank you for the review. That is a very good point — I have added the
#[\SensitiveParameter] attribute to the string parameter so masked values
will no longer appear in backtraces. The change is pushed to the PR.
I understand the use-case may look niche, but I will share benchmark data
in the coming days that addresses the performance aspects raised in this
thread.
Best regards,
Sepehr
Hi Sepehr,
I don’t think benchmarks actually answer the main objection being raised
here. They can show that a dedicated C implementation is faster than
composing substr_replace() and str_repeat(), but they cannot show that this
operation deserves a permanent core API.
Before optimizing it, I’d rather see evidence that the abstraction itself
is common: for example, a corpus analysis of real PHP
applications/frameworks showing how often this exact offset/length masking
pattern occurs and what existing implementations look like. Otherwise we
may just be benchmarking a convenience wrapper.
Also, the current RFC still documents out-of-bounds offsets as returning
the original string unchanged, despite your reply saying it was changed to
fail-closed, and it still says a multi-byte $mask_char is silently reduced
to its first byte. Those semantics should probably be made consistent
first.
And Jordi’s #[SensitiveParameter] point seems especially relevant if
handling sensitive data is the primary motivation.
So I think the order should be: demonstrate the use-case, settle the
contract, then benchmark the implementation.
Best regards,
Pratik Bhujel
در تاریخ شنبه ۱۹ سپتامبر ۲۰۲۶، ۱۵:۲۰ Pratik Bhujel <
prateekbhujelpb@gmail.com> نوشت:
Hi Sepehr,
I don’t think benchmarks actually answer the main objection being raised
here. They can show that a dedicated C implementation is faster than
composingsubstr_replace()andstr_repeat(), but they cannot show that
this operation deserves a permanent core API.Before optimizing it, I’d rather see evidence that the abstraction itself
is common: for example, a corpus analysis of real PHP
applications/frameworks showing how often this exact offset/length masking
pattern occurs and what existing implementations look like. Otherwise we
may just be benchmarking a convenience wrapper.Also, the current RFC still documents out-of-bounds offsets as returning
the original string unchanged, despite your reply saying it was changed to
fail-closed, and it still says a multi-byte $mask_char is silently
reduced to its first byte. Those semantics should probably be made
consistent first.And Jordi’s #[SensitiveParameter] point seems especially relevant if
handling sensitive data is the primary motivation.So I think the order should be: demonstrate the use-case, settle the
contract, then benchmark the implementation.Best regards,
Pratik Bhujel
Hi Pratik,
Thank you for your feedback and for taking the time to review my proposal.
You make some very valid points regarding optimization. I completely agree
with you that performance within the PHP core is critical and must meet the
highest standards.
My main motivation for this RFC is to address a practical need in
real-world scenarios. When I see major frameworks like CakePHP having to
implement custom utility functions for simple tasks like string masking, it
suggests that we are reinventing the wheel. Standardizing this capability
within the PHP core would be a significant benefit to the entire ecosystem.
I would be very happy to hear your specific thoughts on the implementation.
If you have any suggestions on how I can improve the proposal or address
your concerns, I am very open to that discussion.
The evidence for my point is available in my RFC.
Looking forward to hearing from you.
Best regards,
Sepehr
Hi Sepehr,
Thanks. I think we may be talking past each other slightly.
When I see major frameworks like CakePHP having to implement custom utility
functions for simple tasks like string masking, it suggests that we are
reinventing the wheel.
That shows that masking is a real use case, which I don’t dispute. What I’m
still missing is evidence that this specific primitive is what those
projects are repeatedly reinventing.
If CakePHP is part of the motivation, I think the strongest evidence would
be to show an actual CakePHP implementation/use case that could be replaced
by:
str_mask(string, mask_char, offset, length)
without changing its semantics. Even better would be a small prior-art
section with several independent libraries/frameworks converging on roughly
the same operation.
Otherwise, “frameworks implement masking” establishes the problem, but not
necessarily this particular API as the abstraction PHP core should
standardize.
The evidence for my point is available in my RFC.
I did read it. My concern is exactly the distinction above: evidence that
masking exists is different from evidence that this API is the common
missing primitive.
Assuming the recent semantic issues have now been addressed, this is the
part I would focus on before implementation-level optimization. A concrete
before/after from the cited real-world code would make the case much easier
to evaluate.
Best regards,
Pratik Bhujel
On Sat, 19 Sep 2026 20:53:50 +0330, “سپهر محمودی” sepehrphpr@gmail.com
wrote:
در تاریخ شنبه ۱۹ سپتامبر ۲۰۲۶، ۱۵:۲۰ Pratik Bhujel prateekbhujelpb@gmail.com
نوشت:
Hi Sepehr,
I don’t think benchmarks actually answer the main objection being raised
here. They can show that a dedicated C implementation is faster than
composing substr_replace() and str_repeat(), but they cannot show that this
operation deserves a permanent core API.
Before optimizing it, I’d rather see evidence that the abstraction itself
is common: for example, a corpus analysis of real PHP
applications/frameworks showing how often this exact offset/length masking
pattern occurs and what existing implementations look like. Otherwise we
may just be benchmarking a convenience wrapper.
Also, the current RFC still documents out-of-bounds offsets as returning
the original string unchanged, despite your reply saying it was changed to
fail-closed, and it still says a multi-byte $mask_char is silently reduced
to its first byte. Those semantics should probably be made consistent first.
And Jordi’s #[SensitiveParameter] point seems especially relevant if
handling sensitive data is the primary motivation.
So I think the order should be: demonstrate the use-case, settle the
contract, then benchmark the implementation.
Best regards,
Pratik Bhujel
Hi Pratik,
Thank you for your feedback and for taking the time to review my proposal.
You make some very valid points regarding optimization. I completely agree
with you that performance within the PHP core is critical and must meet the
highest standards.
My main motivation for this RFC is to address a practical need in
real-world scenarios. When I see major frameworks like CakePHP having to
implement custom utility functions for simple tasks like string masking, it
suggests that we are reinventing the wheel. Standardizing this capability
within the PHP core would be a significant benefit to the entire ecosystem.
I would be very happy to hear your specific thoughts on the implementation.
If you have any suggestions on how I can improve the proposal or address
your concerns, I am very open to that discussion.
The evidence for my point is available in my RFC.
Looking forward to hearing from you.
Best regards,
Sepehr
در تاریخ یکشنبه ۲۰ سپتامبر ۲۰۲۶، ۰۴:۴۳ Pratik Bhujel <
prateekbhujelpb@gmail.com> نوشت:
Hi Sepehr,
Thanks. I think we may be talking past each other slightly.
When I see major frameworks like CakePHP having to implement custom
utility functions for simple tasks like string masking, it suggests that we
are reinventing the wheel.That shows that masking is a real use case, which I don’t dispute. What
I’m still missing is evidence that this specific primitive is what
those projects are repeatedly reinventing.If CakePHP is part of the motivation, I think the strongest evidence would
be to show an actual CakePHP implementation/use case that could be replaced
by:str_mask(string, mask_char, offset, length)
without changing its semantics. Even better would be a small prior-art
section with several independent libraries/frameworks converging on roughly
the same operation.Otherwise, “frameworks implement masking” establishes the problem, but not
necessarily this particular API as the abstraction PHP core should
standardize.The evidence for my point is available in my RFC.
I did read it. My concern is exactly the distinction above: evidence that
masking exists is different from evidence that this API is the common
missing primitive.Assuming the recent semantic issues have now been addressed, this is the
part I would focus on before implementation-level optimization. A concrete
before/after from the cited real-world code would make the case much easier
to evaluate.Best regards,
Pratik BhujelOn Sat, 19 Sep 2026 20:53:50 +0330, “سپهر محمودی” sepehrphpr@gmail.com
wrote:در تاریخ شنبه ۱۹ سپتامبر ۲۰۲۶، ۱۵:۲۰ Pratik Bhujel
prateekbhujelpb@gmail.com نوشت:Hi Sepehr,
I don’t think benchmarks actually answer the main objection being raised
here. They can show that a dedicated C implementation is faster than
composingsubstr_replace()andstr_repeat(), but they cannot show that this
operation deserves a permanent core API.Before optimizing it, I’d rather see evidence that the abstraction itself
is common: for example, a corpus analysis of real PHP
applications/frameworks showing how often this exact offset/length masking
pattern occurs and what existing implementations look like. Otherwise we
may just be benchmarking a convenience wrapper.Also, the current RFC still documents out-of-bounds offsets as returning
the original string unchanged, despite your reply saying it was changed to
fail-closed, and it still says a multi-byte $mask_char is silently reduced
to its first byte. Those semantics should probably be made consistent first.And Jordi’s #[SensitiveParameter] point seems especially relevant if
handling sensitive data is the primary motivation.So I think the order should be: demonstrate the use-case, settle the
contract, then benchmark the implementation.Best regards,
Pratik Bhujel
Hi Pratik,
Thank you for your feedback and for taking the time to review my proposal.
You make some very valid points regarding optimization. I completely agree
with you that performance within the PHP core is critical and must meet the
highest standards.My main motivation for this RFC is to address a practical need in
real-world scenarios. When I see major frameworks like CakePHP having to
implement custom utility functions for simple tasks like string masking, it
suggests that we are reinventing the wheel. Standardizing this capability
within the PHP core would be a significant benefit to the entire ecosystem.I would be very happy to hear your specific thoughts on the
implementation. If you have any suggestions on how I can improve the
proposal or address your concerns, I am very open to that discussion.The evidence for my point is available in my RFC.
Looking forward to hearing from you.
Best regards,
Sepehr
Hi Pratik,
Fair point! I see what you mean now. You're completely right that just
showing "masking is needed" isn't enough—I need to show why this specific
(string, mask_char, offset, length) signature is the right primitive to
standardize.
To answer that directly:
When people build custom masking logic today, almost everyone lands on
composing substr_replace(), str_repeat(), and strlen():
// What people write today:
$masked = substr_replace(
$pan,
str_repeat('*', $length ?? (strlen($pan) - $offset)),
$offset,
$length ?? (strlen($pan) - $offset)
);
// What str_mask replaces it with:
$masked = str_mask($pan, '*', $offset, $length);
They end up using these exact parameters because offset and length are
already the standard way PHP handles string slicing (like in substr and
substr_replace).
Other frameworks and internal tools (like Laravel's Str::mask) also
converge on this exact signature because it's the most natural fit for
PHP's existing conventions.
The big difference with making this a core primitive isn't just saving a
line of code—it's getting fail-closed error handling (throwing ValueError
instead of silently messing up or leaking data), built-in
#[SensitiveParameter] protection, and avoiding temporary string
allocations in memory.
I've updated the RFC with a quick Before/After comparison to make this
clearer.
Appreciate the feedback, it really helped sharpen the focus!
Cheers,
Sepehr
در تاریخ یکشنبه ۲۰ سپتامبر ۲۰۲۶، ۱۳:۵۲ سپهر محمودی sepehrphpr@gmail.com
نوشت:
در تاریخ یکشنبه ۲۰ سپتامبر ۲۰۲۶، ۰۴:۴۳ Pratik Bhujel <
prateekbhujelpb@gmail.com> نوشت:Hi Sepehr,
Thanks. I think we may be talking past each other slightly.
When I see major frameworks like CakePHP having to implement custom
utility functions for simple tasks like string masking, it suggests that we
are reinventing the wheel.That shows that masking is a real use case, which I don’t dispute. What
I’m still missing is evidence that this specific primitive is what
those projects are repeatedly reinventing.If CakePHP is part of the motivation, I think the strongest evidence
would be to show an actual CakePHP implementation/use case that could be
replaced by:str_mask(string, mask_char, offset, length)
without changing its semantics. Even better would be a small prior-art
section with several independent libraries/frameworks converging on roughly
the same operation.Otherwise, “frameworks implement masking” establishes the problem, but
not necessarily this particular API as the abstraction PHP core should
standardize.The evidence for my point is available in my RFC.
I did read it. My concern is exactly the distinction above: evidence that
masking exists is different from evidence that this API is the common
missing primitive.Assuming the recent semantic issues have now been addressed, this is the
part I would focus on before implementation-level optimization. A concrete
before/after from the cited real-world code would make the case much easier
to evaluate.Best regards,
Pratik Bhujel
Hey Pratik,
Regarding the evidence for common usage: I've actually included a direct
comparison and link in the RFC's "Motivation / Prior Art" section at the
very end. It demonstrates how existing code patterns directly map to the
proposed str_mask() signature.
Would be great if you could glance over it when you have a moment. Let me
know if that addresses your point!
Best,
Sepehr
در تاریخ شنبه ۱۹ سپتامبر ۲۰۲۶، ۰۲:۱۳ Casper Langemeijer langemeijer@php.net
نوشت:
8On Fri, Sep 18, 2026, at 20:26, سپهر محمودی wrote:
As part of this, I would like to propose a new native function called
str_mask().Not useful.
Easily implemented in user-space.
Performance would never be an issue for a function typically used on small
strings a few times per request.
In the multi-million-line web application I work on this probably would
not be used even once.Please stop this. Your mails read like AI slop, and your proposals are of
very poor quality. I suspect that there are more than a few thousand humans
reading this list, and you are wasting their time.Please don't see this as a personal attack. It's the work that is not good
enough, not you as a person.Greetings, Casper
Hi Casper,
My responses to your questions are summarized in the benchmark tests, which
I am currently conducting. I prefer to avoid any further discussion
regarding AI to keep our focus strictly on the technical merits of the
proposal.
Best regards,
Sepehr