Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109326 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61416 invoked from network); 26 Mar 2020 10:54:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Mar 2020 10:54:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C0BDA1804C5 for ; Thu, 26 Mar 2020 02:19:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 26 Mar 2020 02:19:28 -0700 (PDT) Received: by mail-lj1-f193.google.com with SMTP id i20so5601513ljn.6 for ; Thu, 26 Mar 2020 02:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5exBeHaxfjECoFSvols1ss3/ATnESsHigSqL2hmD+K8=; b=DK5altBPOSm+x3cUJDPpA1GV1PDNJV+wMlUHY9W+5IyMICwQ4Laeanb/mV+cFkGOsq vCJWizknu2+i+F3f/M7FG3HJIt8YKdcy3YmVcwnjs1InFSALZ+ML9DF/z9yzfMFURYUd gZJ4OPw8bsh5HM7W5NYdFSg0L8LweIzFcmdpgxhOCfi5YC3GVk6CVKEwrEzBie0tCHYB UrjlJq69epCA4EqRDcrzLXygRvFhTDy05g3m8odmZ7q7n8T7zCGhEArYJ9sOpJs+GfCW VTWnBVu+m6aVrOO7GsmbVEcB9T2QqRT4xBTQfSGk7ozWcJHImnJw+BMdu4YKxHxBohH6 mPcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5exBeHaxfjECoFSvols1ss3/ATnESsHigSqL2hmD+K8=; b=OKYuPnblF/yqWGAAxLocZ5REC1EmClo9706o2UEmm9uSb/4V+jioqZ8iKfhcFC6GnY Q1YCtcJgo17jxiNLAdoivfazMBK9qu/zk/5azi1u4sXF0zS6EgtlN9GyIWThxGwJ/k7u 3dFYliAUBORevxBxwuCYweDIidsDCbsyErQQdfJdMmiZW6+EL1ixAoP0D6D98Q439i1G YXnz2AaR1aquZBDGmAWTN/45HkT6R9LH8/YzZ+5MCfLwqeh+iy/NOKAWBB64dGjXrbkK LPU+1ixbJBZRc8zOMlUP/8RYlmv70GSHjbma2bzInPZRvFwjhpMeCnkVrtyntAml3kh0 5cpA== X-Gm-Message-State: AGi0PubHiZNZe56gvuTnwdFRn2rorTBNTfvtpUoHNlMxJtnh4hCOyneX Lk1wG6qx/weTIfmGcwQ9Ykd4ws3REhRNYQxVxQ== X-Google-Smtp-Source: APiQypLQv+DLloV+CiXClJGUTQQ8UVzx3zHQn61A1bJf9afYEVhoO7dix36ElBMCpWgrMHJks+bM6l7apmQr0puKBJE= X-Received: by 2002:a2e:7a0a:: with SMTP id v10mr2262375ljc.143.1585214365219; Thu, 26 Mar 2020 02:19:25 -0700 (PDT) MIME-Version: 1.0 References: <366565615b320e2f6b0a2d75298d84e7@wkhudgins.info> In-Reply-To: Date: Thu, 26 Mar 2020 10:19:13 +0100 Message-ID: To: will@wkhudgins.info Cc: Nikita Popov , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] RFC Raised for str_starts_with and str_ends_with From: guilliam.xavier@gmail.com (Guilliam Xavier) On Thu, Mar 26, 2020 at 9:54 AM Nikita Popov wrote: > > On Thu, Mar 26, 2020 at 3:36 AM wrote: > > > Hi, > > > > Hope everyone is doing alright. I just raised a new RFC > > (https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions , > > github patch: https://github.com/php/php-src/pull/5300) for adding > > str_starts_with and str_ends_with to PHP. I would like to open this RFC > > up to discussion. > > > > I raised a similar RFC about 9 months ago > > (https://wiki.php.net/rfc/add_str_begin_and_end_functions) that was > > narrowly rejected. A major criticism of that RFC was the inclusion of > > case-insensitive versions of str_starts_with and str_ends_with. I have > > incorporated feedback from that experienced and narrowed the new RFC to > > only propose str_starts_with and str_ends_with. > > > > I was in favor of the previous RFC, so also in favor of this one :) These > are going to complement the recently added str_contains() nicely. > > Notes on text: > > > After that RFC was closed, a code freeze was in place for PHP8's release. > PHP8 has now been released and several individuals have requested the > str_starts_with and str_ends_with functionality again. This is a simple but > highly desired functionality for PHP. > > I think you mean PHP 7.4 here. PHP 8.0 is not yet released, and not in > feature freeze either. > > > Add str_starts_with, and str_starts_with_ci() functions > > The second function should probably be str_ends_with() :) > > Nikita Hi Will, First, thank you for re-working on this, I would love to see it happen! :) Nevertheless, apart from some typos (already reported), I still think the RFC needs a "Motivation" section with actual examples of userland implementations (using functions like str[r]pos/strncmp/substr[_compare]... often with strlen, or even preg_match/fnmatch... [with escaping]) and the downsides of each (e.g. CPU-inefficient, memory-inefficient, error-prone, hard to understand...) plus how they handle empty strings. (And also probably shorten the introduction ^^ or move parts into a new subsection) PS: you could also add a link to the str_contains RFC Best regards, -- Guilliam Xavier