Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94806 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70615 invoked from network); 2 Aug 2016 22:45:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Aug 2016 22:45:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:33224] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/80-00814-18221A75 for ; Tue, 02 Aug 2016 18:45:23 -0400 Received: (qmail 84803 invoked by uid 89); 2 Aug 2016 22:45:18 -0000 Received: from unknown (HELO mail-qk0-f176.google.com) (yohgaki@ohgaki.net@209.85.220.176) by 0 with ESMTPA; 2 Aug 2016 22:45:18 -0000 Received: by mail-qk0-f176.google.com with SMTP id v123so56122785qkh.3 for ; Tue, 02 Aug 2016 15:45:16 -0700 (PDT) X-Gm-Message-State: AEkoouusBJ2EJWd4YyR8AAaEbJV0wxBp4qX27nwhVh1888wpN0ea0PXa5XRcb1pbLOfasVlKCZ9DFShOadkZDQ== X-Received: by 10.55.44.134 with SMTP id s128mr76158869qkh.198.1470177910002; Tue, 02 Aug 2016 15:45:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.85.242 with HTTP; Tue, 2 Aug 2016 15:44:29 -0700 (PDT) In-Reply-To: References: <8442f1fa5544b2ca03e7cebbc64e8e5c@wkhudgins.info> Date: Wed, 3 Aug 2016 07:44:29 +0900 X-Gmail-Original-Message-ID: Message-ID: To: David Rodrigues Cc: Sara Golemon , will@wkhudgins.info, PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] RFC Posted for str_begins and str_ends functions From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi David, On Tue, Aug 2, 2016 at 10:36 AM, David Rodrigues wrote: > Sara Golemon wrote: >> Feeling "meh" on it (neither for nor against), but I would consider >> consistency with other str*() functions by making case-insensitivity >> live in separate functions rather than as a parameter. e.g. >> str_begins(), str_ibegins(), str_ends(), end_iends() > > I guess that "i" isn't appliable when it have slashes. > In this case, functions should be: strbegins, stribegins, strends, striends. > In all case, I think that is better a third parameter and keep underlined. This is difficult issue. String function names are inconsistent currently. It is better to stick to CODING_STANDARDS naming convention for new function names. Therefore, new string functions are better to be named str_*() unless they are too strange. e.g. http://php.net/manual/en/function.str-replace.php http://php.net/manual/en/function.str-ireplace.php I would like to fix function name inconsistencies by having aliases in near future. https://wiki.php.net/rfc/consistent_function_names It might be okay to have "s" in function names, but if we want to be consistent, str_replace -> str_replaces str_ireplace -> str_ireplaces IMO, following names are better for consistency. str_begin str_ibegin str_end str_iend In addition, str_replace() has seach_value at first, so signature might be boolean str_begin(string $search_value, string $str, [boolean $case_sensitive = true]) boolean str_end(string $search_value, string $str, string $search_value [boolean $case_sensitive = true]) However, strstr() (and other str functions without "_". e.g. strpos/stripos/strrpos/strripos) has search_value as the 2nd parameter. If we follow this format, current signature is fine. It may be better sort out and fix consistency issues first, then add new functions. Otherwise, we may introduce more consistency issues. Regards, BTW, having "i" is more readable. str_ibegin("searchthis", $str); is more readable than str_begin("seachthis", $str, TRUE); as programmer does not have to know that's the TRUE means. It's small thing, but small things add up. -- Yasuo Ohgaki yohgaki@ohgaki.net