Re: [RFC] str_icontains
| From: | Adam Cable | Date: | Tue, 24 Jun 2025 08:18:03 +0000 |
| Subject: | Re: [RFC] str_icontains | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127743@lists.php.net to get a copy of this message | ||
On Tue, Jun 24, 2025 at 12:20 AM Larry Garfield <larry@garfieldtech..com>
wrote:
> On Sun, Jun 15, 2025, at 3:12 PM, Adam Cable wrote:
> > Hello internals,
> >
> > I'd like to present my first RFC - str_icontains, a case-insensitive
> > friend of str_contains
> >
> > RFC: https://wiki.php.net/rfc/str_icontains
> > PR (including tests):
> > https://github.com/php/php-src/pull/18705
> >
> > Previous discussion: https://externals.io/message/127504
> >
> > Thanks,
> > Adam
>
> When str_contains() was added, a case-insensitive version was deliberately
> omitted in favor of "just use strtolower() yourself." Have you gone back
> to see the arguments for that to determine if they're still relevant?
>
> (I don't recall the details; I think one of them was function count
> explosion, but I think there were more.)
>
> --Larry Garfield
>
Thanks Larry.
Yes, I did spend time reading through the past discussions on both
str_contains and the str_starts/end_with functions.
I think initial RFCs failed because (a) people felt that the functions
didn't necessarily bring a whole heap of functionality above userland code
and (b) the debate about whether case-insensitive versions should be
included.
Now that these functions exist, it seems weird as a PHP user that
case-insensitive versions aren't available to easily switch between.
Obviously we have the UTF-8 question that I've detailed, but I'm hoping
adding this will solve a tiny issue where people expect this function to
exist, but it doesn't.
Adam