Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106188 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69259 invoked from network); 9 Jul 2019 04:05:52 -0000 Received: from unknown (HELO gateway9.unifiedlayer.com) (70.40.200.246) by pb1.pair.com with SMTP; 9 Jul 2019 04:05:52 -0000 Received: from cm1.websitewelcome.com (unknown [192.185.0.102]) by gateway9.unifiedlayer.com (Postfix) with ESMTP id 4E2BD200A5F15 for ; Mon, 8 Jul 2019 20:25:21 -0500 (CDT) Received: from krieger.asoshared.com ([65.99.237.153]) by cmsmtp with ESMTP id kesjhvNFowLnQkesjh7Z8u; Mon, 08 Jul 2019 20:25:21 -0500 X-Authority-Reason: nr=8 Received: from krieger.asoshared.com ([65.99.237.153]:36555) by krieger.asoshared.com with esmtpa (Exim 4.91) (envelope-from ) id 1hkesi-002rua-SU; Mon, 08 Jul 2019 21:25:20 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 08 Jul 2019 21:25:20 -0400 To: Ben Ramsey Cc: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= , Theodore Brown , PHP internals In-Reply-To: <24737D9E-EAAE-4763-913A-CE1CD291EC5E@benramsey.com> References: <8442f1fa5544b2ca03e7cebbc64e8e5c@wkhudgins.info> <683c5da474e13283030cac3d0c0ec080@wkhudgins.info> <2c37999d1e5372ae6ab48bfce5420796@wkhudgins.info> <2CF672F8-12F5-4D37-8B8C-591A6E695220@benramsey.com> <78034520cdb610d923e25d47ed718938@wkhudgins.info> <000a01d52e91$2a4b6f20$7ee24d60$@jhdxr.com> <93528f103c149b7c48e8f35914049d06@wkhudgins.info> <97884add-88fd-e09e-92c6-2c1b68c579f5@xs4all.nl> <22ac19ecaf897370facfe9fd0a8b1993@wkhudgins.info> <0f8ab2d1-c308-7168-0aba-a5bcf327c3ad@telia.com> <4d340e64db8d81f47cd7e4f7d3a4c268@wkhudgins.info> <660880c5-6273-1f6d-2181-3cb4c67fb508@telia.com> <24737D9E-EAAE-4763-913A-CE1CD291EC5E@benramsey.com> Message-ID: X-Sender: will@wkhudgins.info User-Agent: Roundcube Webmail/1.3.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - krieger.asoshared.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - wkhudgins.info X-BWhitelist: no X-Source-IP: 65.99.237.153 X-Source-L: Yes X-Exim-ID: 1hkesi-002rua-SU X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: krieger.asoshared.com [65.99.237.153]:36555 X-Source-Auth: will@wkhudgins.info X-Email-Count: 1 X-Source-Cap: d2todWRnaW47d2todWRnaW47a3JpZWdlci5hc29zaGFyZWQuY29t X-Local-Domain: yes Subject: Re: [PHP-DEV] [VOTE] Voting opens for str_starts_with and ends_with functions From: will@wkhudgins.info On 2019-07-08 17:52, Ben Ramsey wrote: >> On Jul 8, 2019, at 13:09, Björn Larsson >> wrote: >> >> Having this _ci postfix is a new way of indicating case >> insensitivity. >> I think that it might add to negative votes. Personally I think it's a >> good idea to mimic existing ways, even if they are a bit awkward. >> >> How about using a flag or following "tradition", like stri_starts_with >> & stri_ends_with or str_istarts_with & str_iends_with? That would >> follow strstr / stristr and str_replace / str_ireplace. >> >> I have no voting rights though. > > > I made this recommendation earlier in the other thread > (), but it didn’t get any > traction or response: > >> maybe the signatures could be revised to pass a third parameter? >> >> str_starts_with($haystack, $needle, $case_sensitive = true): bool > > Since voting has already begun, is this something that could still be > considered? > > -Ben Thanks for the interest everyone! I've been following the email thread and have a few thoughts. - At one point I had it set to take case sensitivity as a parameter (https://github.com/php/php-src/pull/2049/commits/f89d8edc5f32d8a4b702699209e72d864e2ca440). That isn't a bad idea IMO. I changed it to have split functions to match str_ireplace, stripos, etc. - I agree the *_ci naming convention is different than most of the existing codebase, but a lot of discussion during the process led to the *_ci naming convention. And while the *_ci naming convention isn't traditional, it does seem more intuitive. The i is easier to read in something short like "str_ireplace" but kind of gets lost in something long like "str_istarts_with". - I'd considered splitting the vote into 3 parts: 1) str_starts_with and str_ends_with 2) str_starts_with_ci and str_ends_with_ci 3) The mb_* functions. But I decided against that as I felt that might be overly splitting up the proposal. If the main issue is naming and not functionality, I am happy to rework the RFC (if it fails) to be more palatable. I primarily would like to add this functionality to PHP, regardless of the naming. In my opinion one of the nice things about PHP is that it comes with so many things under the hood. As a user of the language that is something I appreciate. A lot of powerful functionality is baked into the language and that functionality is available on almost every web host. A language like Python or Java just can't compare in that respect. Even NodeJS requires an extensive amount of packages to accomplish even simple tasks. PHP is nice because it ships with "batteries" included. Sure, that brings some issues along with it, but that is as much a strength of the language as it is a challenge. Adding a common task like starts_with and ends_with seems like a reasonable thing to do. Thanks, Will