Re: [RFC] Deprecations for PHP 8.4
| From: | mickmackusa | Date: | Sat, 29 Jun 2024 21:23:12 +0000 |
| Subject: | Re: [RFC] Deprecations for PHP 8.4 | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-124063@lists.php.net to get a copy of this message | ||
>
> If one can easily use a function incorrectly in a way that is not
> *immediately* apparent, then I consider the function to be badly
> designed.
>
Does that philosophy also cover preg_quote()? I've lost count of the
number of times that I've seen it used in Stack Overflow answers without a
second parameter (including array_map('preg_quote', $array)) and its
returned value used in a regex that has foward slashes as delimiters.
Additionally, it is an unintuitively named function; it doesn't actually
"quote" anything -- it \e\s\c\a\p\e\s characters. This makes life
unnecessarily harder for devs who are new to PHP who need to find the regex
escaping function.
Would it be reasonable to create
preg_escape() which also (sometimes
unnecessrily) includes the (de facto default delimiter) forward slash in
its default list of escaped characters so that preg_quote() could
eventually be deprecated? As far as I know this would do no harm, will
prevent holes in code, and make PHP more intuitive.
Mick
>