Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-03-03 Thread Andreas Heigl
Am 03.03.20 um 14:29 schrieb Nicolas Grekas: > Le mar. 3 mars 2020 à 11:04, Rowan Tommins a > écrit : > >> On Tue, 3 Mar 2020 at 08:46, Andreas Heigl wrote: >> >>> >>> While it is mainly aimed at being a mere convenience-function that could >>> also be easily implemented in userland it misses

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-03-03 Thread Nicolas Grekas
Le mar. 3 mars 2020 à 11:04, Rowan Tommins a écrit : > On Tue, 3 Mar 2020 at 08:46, Andreas Heigl wrote: > > > > > While it is mainly aimed at being a mere convenience-function that could > > also be easily implemented in userland it misses one main thing IMO when > > handling unicode-strings: N

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-03-03 Thread Rowan Tommins
On Tue, 3 Mar 2020 at 08:46, Andreas Heigl wrote: > > While it is mainly aimed at being a mere convenience-function that could > also be easily implemented in userland it misses one main thing IMO when > handling unicode-strings: Normalization. > > While I would love to see more functionality fo

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-03-03 Thread Andreas Heigl
Hey all. Just a short note why I voted against the current implementation of the str_contains functionality. While it is mainly aimed at being a mere convenience-function that could also be easily implemented in userland it misses one main thing IMO when handling unicode-strings: Normalization.

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-03-02 Thread Nikita Popov
On Mon, Mar 2, 2020 at 8:10 PM Andrea Faulds wrote: > Hi, > > Philipp Tanlak wrote: > > I like to elaborate on Nikitas response: I don't think a mb_str_contains > is > > necessary, because the proposed function does not behave differently, if > > the input strings are multibyte strings. > > This

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-03-02 Thread Andrea Faulds
Hi, Philipp Tanlak wrote: I like to elaborate on Nikitas response: I don't think a mb_str_contains is necessary, because the proposed function does not behave differently, if the input strings are multibyte strings. This is not true for all character encodings. For UTF-8 it is correct, but co

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-17 Thread Rowan Tommins
On Mon, 17 Feb 2020 at 13:38, Pierre Joye wrote: > > Btw, while some mbstring references I I mentioned, I do like the ICU search > implementation as well. > > http://userguide.icu-project.org/collation/icu-string-search-service > > It handles a lot of cases based on locales. > That's a lovely e

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-17 Thread Pierre Joye
hello, On Fri, Feb 14, 2020, 6:54 PM Nikita Popov wrote: > On Fri, Feb 14, 2020 at 10:18 AM Philipp Tanlak > wrote: > > > Hello PHP Devs, > > > > I would like to propose the new basic function: str_contains. > > > > The goal of this proposal is to standardize on a function, to check > weather >

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-17 Thread Philipp Tanlak
Am Mo., 17. Feb. 2020 um 12:56 Uhr schrieb Nikita Popov < nikita@gmail.com>: > On Mon, Feb 17, 2020 at 12:49 PM Benjamin Morel > wrote: > >> Thanks for the karma! An RFC has been created: >>> https://wiki.php.net/rfc/str_contains >> >> >> >> Something that's missing from the RFC is the behavi

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-17 Thread Nikita Popov
On Mon, Feb 17, 2020 at 12:49 PM Benjamin Morel wrote: > Thanks for the karma! An RFC has been created: >> https://wiki.php.net/rfc/str_contains > > > > Something that's missing from the RFC is the behaviour when $needle is an > empty string: > > str_contains('abc', ''); > str_contains('', ''); >

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-17 Thread Benjamin Morel
> > Thanks for the karma! An RFC has been created: > https://wiki.php.net/rfc/str_contains Something that's missing from the RFC is the behaviour when $needle is an empty string: str_contains('abc', ''); str_contains('', ''); Will these always return false? — Benjamin

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-17 Thread Philipp Tanlak
Am Mo., 17. Feb. 2020 um 10:53 Uhr schrieb Nikita Popov < nikita@gmail.com>: > On Mon, Feb 17, 2020 at 10:03 AM Philipp Tanlak > wrote: > >> Now that we've talked about the pros and cons of case-insensitivity and >> multibyte variants, I'm still unsure what your opinions on those are. >> >> *

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-17 Thread Nikita Popov
On Mon, Feb 17, 2020 at 10:03 AM Philipp Tanlak wrote: > Now that we've talked about the pros and cons of case-insensitivity and > multibyte variants, I'm still unsure what your opinions on those are. > > * Should we include a case-insensitive variant (str_icontains) ? > * Should we include multi

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-17 Thread Philipp Tanlak
Now that we've talked about the pros and cons of case-insensitivity and multibyte variants, I'm still unsure what your opinions on those are. * Should we include a case-insensitive variant (str_icontains) ? * Should we include multibyte variants (mb_str_icontains) ? Slightly off-topic: Also, sinc

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-16 Thread Guilliam Xavier
On Fri, Feb 14, 2020 at 11:14 AM G. P. B. wrote: > > Moreover, checking for a substring to start/end a string seems > to be > fitting for the current strpos functions. Maybe in terms of semantics (`0 === strpos($haystack, $needle)`), but suboptimal in terms of performance, especially when $haysta

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-14 Thread Philipp Tanlak
Am Fr., 14. Feb. 2020 um 12:54 Uhr schrieb Nikita Popov < nikita@gmail.com>: > On Fri, Feb 14, 2020 at 10:18 AM Philipp Tanlak > wrote: > >> Hello PHP Devs, >> >> I would like to propose the new basic function: str_contains. >> >> The goal of this proposal is to standardize on a function, to

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-14 Thread Nikita Popov
On Fri, Feb 14, 2020 at 10:18 AM Philipp Tanlak wrote: > Hello PHP Devs, > > I would like to propose the new basic function: str_contains. > > The goal of this proposal is to standardize on a function, to check weather > or not a string is contained in another string, which has a very common > us

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-14 Thread Claude Pache
> Le 14 févr. 2020 à 10:17, Philipp Tanlak a écrit : > > Hello PHP Devs, > > I would like to propose the new basic function: str_contains. > > The goal of this proposal is to standardize on a function, to check weather > or not a string is contained in another string, which has a very common

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-14 Thread G. P. B.
On Fri, 14 Feb 2020 at 10:58, Aegir Leet wrote: > I generally like the idea, but it seems many (most?) real-world > implementations actually use mb_strpos() !== false by default. > > > https://github.com/danielstjules/Stringy/blob/df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e/src/Stringy.php#L206-L215

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-14 Thread Aegir Leet
I generally like the idea, but it seems many (most?) real-world implementations actually use mb_strpos() !== false by default. https://github.com/danielstjules/Stringy/blob/df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e/src/Stringy.php#L206-L215 https://github.com/illuminate/support/blob/6eff6cff19f7ad

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-14 Thread Peter Bowyer
On Fri, 14 Feb 2020 at 09:18, Philipp Tanlak wrote: > I would like to propose the new basic function: str_contains. > > The proposed signature for this function follows the conventions of other > signatures of string functions and should look like this: > > str_contains(string $haystack, stri