On 2019-07-08 17:52, Ben Ramsey wrote:
On Jul 8, 2019, at 13:09, Björn Larsson <bjorn.x.lars...@telia.com>
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
(<https://externals.io/message/94787#106035>), 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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php