Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95126 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84831 invoked from network); 13 Aug 2016 23:17:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2016 23:17:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=simon@simon.geek.nz; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=simon@simon.geek.nz; sender-id=pass Received-SPF: pass (pb1.pair.com: domain simon.geek.nz designates 128.199.154.101 as permitted sender) X-PHP-List-Original-Sender: simon@simon.geek.nz X-Host-Fingerprint: 128.199.154.101 3.91carriage.com Received: from [128.199.154.101] ([128.199.154.101:36076] helo=mail.91carriage.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/87-36656-57AAFA75 for ; Sat, 13 Aug 2016 19:17:12 -0400 Received: from [10.1.1.8] (unknown [180.200.147.155]) by mail.91carriage.com (Postfix) with ESMTPSA id D1C5D12BBA4; Sat, 13 Aug 2016 23:17:05 +0000 (UTC) Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_05FCEBDE-6645-441C-9FA9-C17D2D4308D9"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail In-Reply-To: Date: Sun, 14 Aug 2016 09:17:01 +1000 Cc: internals@lists.php.net Message-ID: References: <8442f1fa5544b2ca03e7cebbc64e8e5c@wkhudgins.info> To: will@wkhudgins.info X-Mailer: Apple Mail (2.3124) Subject: Re: [PHP-DEV] RFC Posted for str_begins and str_ends functions From: simon@simon.geek.nz (Simon Welsh) --Apple-Mail=_05FCEBDE-6645-441C-9FA9-C17D2D4308D9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 14/08/2016, at 2:47 AM, will@wkhudgins.info wrote: >=20 > On 2016-08-13 04:34, Simon Welsh wrote: >>> On 2/08/2016, at 8:52 AM, will@wkhudgins.info wrote: >>> Hello, >>> I recently emailed the group about submitting an RFC for = str_begins() and str_ends() functions. The RFC has now been officially = submitted and is viewable at: >>> https://wiki.php.net/rfc/add_str_begin_and_end_functions >>> The github PR may be found at: >>> https://github.com/php/php-src/pull/2049 >>> Hope to be hearing about this, >>> Will >> 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). >> 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. >> [1]: >> = https://github.com/sugarcrm/sugarcrm_dev/blob/ae189cfa4ed4edd6a4e1e0d9d1d5= ec66f46a0b74/include/utils.php#L2082-L2090 >> -- >> Simon Welsh >=20 > You are correct, functions like strpos and strstr do follow (haystack, = needle) but functions like str_replace follow the format (needle, = haystack). Because I did these functions with the underscore, it made = sense to make the functions follow the format found in other str_* = functions. If the functions were changed to be strbegin, stribegin, = strend, and striend, then it would make sense to follow the (haystack, = needle) format. However, I think adding the underscore greatly improves = the readability of these functions. And if the functions are named with = an underscore, I think it should follow the format found in the other = underscore functions. str_replace and str_ireplace are the only str_* functions that don=E2=80=99= t take the full string (haystack) as the first argument. str_pad, = str_repeat, str_split and str_word_count all take the full string first = even if there are other compulsory arguments. Also, these functions are replacements for current usage of = strpos/strrpos/substr_compare, so I feel like the argument ordering = should match those rather than another function that isn=E2=80=99t = closely related in functionality. >=20 > Good call on the BC break, I had not thought about it breaking = userland functions with the same name. >=20 > -Will -- Simon Welsh --Apple-Mail=_05FCEBDE-6645-441C-9FA9-C17D2D4308D9 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJXr6puAAoJEPbD7ZRQAm4a1roQAKfEztNOmOq0zPPdH4kGWW19 cTgOmEUAcM7ByL8LN6oe2ftEVDXTQFez5MoJmoslB+W3J8EYOwMJUeeQZ93CO+UV /VuNMl0EuQbIPWqZ/KFulpfYNv6AUAWgOCE9efpljD7QJcz1o7aXQxicY643E3VY HMwUuukvNvv95nJXMe5aLOGAvp1fJDD7j0pdypTUOLtgpRS7uMBOnbpy16lhmoGg ddPDYn7UySvTLsqBSvyXZi0Ayk77rdRkvfTi8jnx8O+tULwM86WQM5IvydsIeRqL NK4dJnXA+VXGA1v6E8n93EnH7k5UzROB02GtQRP8ZfUm09riQQkdW0z3pOwkuO5C Xb2gNLL6jq4nYJr4oBJBMWlOqBMS/aXW34Q+WsEZbWP2JQetGwLjG9Ezjf0WqS+w 5ChsILFttpg3bxT4ptFREaZD6fPJoM7x416kgxIsqrNIfFy5z3U04sWKIVeVIbmZ orpuJig4JaQ+sistccVGVz67aGumC8PRBeNlsZ7i0/9Iyj7fBkcWX4Kfp3Lib6du npeTlNYIqTogbtR0dQi/E3WDVGmv53w6Vxnu9KxR2Ah7toeWINwNfMshRMIbyklW deFKQLPR2K/y+WCNiJGCVaALXG5jQXkQZ7CD4EsRWJzHhQ/nWUPiFPXrAZmPCndD Pin9Q+rVWPthKtIwVbkM =eK+P -----END PGP SIGNATURE----- --Apple-Mail=_05FCEBDE-6645-441C-9FA9-C17D2D4308D9--