Re: [rfc] str_mask function
| From: | Morgan | Date: | Mon, 21 Sep 2026 00:32:10 +0000 |
| Subject: | Re: [rfc] str_mask function | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132568@lists.php.net to get a copy of this message | ||
On 2026-09-21 03:48, سپهر محمودی wrote:
Just to clarify the intent:It's reasonable to apply #[\SensitiveParameter] to the $password field of openssl_password_hash() or PDO::connect() because you are by definition passing a sensitive value (a password) in that parameter. But for low-level string manipulation? Strings are arbitrary sequences of bytes and "sensitivity" is not an inherent property of such things. Morganstr_mask()is designed not as domain/ business logic (like slugification), but as a low-level string manipulation primitive—very similar to existing core primitives likestr_pad(),substr_replace(), andstr_repeat(). The main reasons for considering it at the core level rather than userland/PECL are: 1. First-class integration with#[\SensitiveParameter]to ensure safe handling of sensitive/PII data in stack traces. 2. Providing a strict, fail-closed contract natively without the allocation and performance overhead of composing multiple userland calls. See, this #[\SensitiveParameter] thing is what makes it look to me like business logic rather than low-level; it assumes that what is being masked is - well - sensitive, according to some criterion. There might be other reasons why someone will want to mask part of a string that _isn't_ sensitive (anyone for a game of Hangman?).