Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95120 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59098 invoked from network); 13 Aug 2016 16:47:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2016 16:47:20 -0000 Authentication-Results: pb1.pair.com header.from=will@wkhudgins.info; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=will@wkhudgins.info; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain wkhudgins.info from 23.83.218.22 cause and error) X-PHP-List-Original-Sender: will@wkhudgins.info X-Host-Fingerprint: 23.83.218.22 bonobo.tulip.relay.mailchannels.net Received: from [23.83.218.22] ([23.83.218.22:16874] helo=bonobo.tulip.relay.mailchannels.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/93-36656-21F4FA75 for ; Sat, 13 Aug 2016 12:47:17 -0400 X-Sender-Id: asmallorange|x-authuser|will@wkhudgins.info Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id DEAE71BDD03; Sat, 13 Aug 2016 16:47:09 +0000 (UTC) Received: from krieger.asoshared.com (ip-10-229-10-199.us-west-2.compute.internal [10.229.10.199]) by relay.mailchannels.net (Postfix) with ESMTPA id 3FD801BD8F9; Sat, 13 Aug 2016 16:47:09 +0000 (UTC) X-Sender-Id: asmallorange|x-authuser|will@wkhudgins.info Received: from krieger.asoshared.com ([TEMPUNAVAIL]. [10.107.128.240]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.7.6); Sat, 13 Aug 2016 16:47:09 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: asmallorange|x-authuser|will@wkhudgins.info X-MailChannels-Auth-Id: asmallorange X-MC-Loop-Signature: 1471106829529:1550480052 X-MC-Ingress-Time: 1471106829529 Received: from [::1] (port=25319 helo=krieger.asoshared.com) by krieger.asoshared.com with esmtpa (Exim 4.87) (envelope-from ) id 1bYc5P-0008RC-GZ; Sat, 13 Aug 2016 12:47:03 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Date: Sat, 13 Aug 2016 12:47:03 -0400 To: Simon Welsh Cc: internals@lists.php.net In-Reply-To: References: <8442f1fa5544b2ca03e7cebbc64e8e5c@wkhudgins.info> Message-ID: X-Sender: will@wkhudgins.info User-Agent: Roundcube Webmail/1.1.4 X-AuthUser: will@wkhudgins.info Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC Posted for str_begins and str_ends functions From: will@wkhudgins.info On 2016-08-13 04:34, Simon Welsh wrote: >> On 2/08/2016, at 8:52 AM, will@wkhudgins.info wrote: >>=20 >> Hello, >>=20 >> I recently emailed the group about submitting an RFC for str_begins()=20 >> and str_ends() functions. The RFC has now been officially submitted=20 >> and is viewable at: >>=20 >> https://wiki.php.net/rfc/add_str_begin_and_end_functions >>=20 >> The github PR may be found at: >>=20 >> https://github.com/php/php-src/pull/2049 >>=20 >> Hope to be hearing about this, >>=20 >> Will >=20 > Firstly, the argument ordering is the wrong way round for a string > function. String functions =E2=80=94 especially search-related ones =E2= =80=94 are > haystack, needle (see strpos, strstr, strcspn, strpbrk, etc). >=20 > Secondly, I feel like this RFC does need to include that it=E2=80=99s a= BC > break by introducing new global functions. A quick search shows that > SugarCRM[1] already implements str_begin and str_end functions and > there=E2=80=99s likely to be other projects that do too. >=20 > [1]: > https://github.com/sugarcrm/sugarcrm_dev/blob/ae189cfa4ed4edd6a4e1e0d9d= 1d5ec66f46a0b74/include/utils.php#L2082-L2090 > -- > Simon Welsh You are correct, functions like strpos and strstr do follow (haystack,=20 needle) but functions like str_replace follow the format (needle,=20 haystack). Because I did these functions with the underscore, it made=20 sense to make the functions follow the format found in other str_*=20 functions. If the functions were changed to be strbegin, stribegin,=20 strend, and striend, then it would make sense to follow the (haystack,=20 needle) format. However, I think adding the underscore greatly improves=20 the readability of these functions. And if the functions are named with=20 an underscore, I think it should follow the format found in the other=20 underscore functions. Good call on the BC break, I had not thought about it breaking userland=20 functions with the same name. -Will