Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119177 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 18056 invoked from network); 16 Dec 2022 15:44:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Dec 2022 15:44:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 12537180544 for ; Fri, 16 Dec 2022 07:44:56 -0800 (PST) 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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 16 Dec 2022 07:44:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1671205494; bh=M/FtBqzjo4vPf1GhQ+T/BckdZmsby7KETD8wu3rB4F0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=mXXn7Tpq4bxxshgljNfJd2X8zJrsSiQvcaBRo0f98fH45x7aTDqWwd1vfRnrmIq6C sjCqWjtfoY75q9cxBF4FBXgcizklHedqyFRxnRaQZEBUKmyH26g1Pw3HMq9JRcH6DN dmNAHU+CsFIwLXhHdksf6uswpmHl8gAq+WB9MeMKK41lTKaqXzNyB8SLiFxzTIgDuO D5/dC/FjSoLjjOfaw5n3mTF/4DuizIrD8igJwzEZ/15pkkJO+vcDX/5TLHjoMHiyBj L9UZ0o6e8/qot+JZouWUA9wt/OiH7hTEG6yq29EuDZWywQeiVBmri5iuYdXYTGiIRW bMH5MUlYbifNg== Message-ID: Date: Fri, 16 Dec 2022 16:44:53 +0100 MIME-Version: 1.0 Content-Language: en-US To: Derick Rethans Cc: PHP Developers Mailing List References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Unicode Text Processing From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi On 12/16/22 14:55, Derick Rethans wrote: >> ---------- >> >> getPositionOfFirstOccurrence(): >> >> I agree this is too long. How about: >> >> - findOffset() >> - findOffsetLast() >> >> And for returnFromFirstOccurence(): >> >> - startingWith() >> - startingWithLast() > > I have included these as suggested names. I suspect we'll get more :-) > You accidentally put 'startingWithLast' into the 'contains' section. But thinking about the name a little more: 'At' instead of 'With' might be a little more appropriate, because $a->startingWith($b) could also mean '$b . $a' … which brings me to: ---------- 1. How is concatenation expected to work? Will '.' be overloaded or should folks use: \Text::join([ $prefix, '-' $suffix, ], ''); or similar? Perhaps an explicit \Text::concat(…) method should be provided? ---------- 2. As I've noted in the discussion for List\unique: I think iterators should not be second-class citizen to arrays. Thus I propose to change \Text::join() to: /** @param iterable<\Text|string> $elements */ public static function join(iterable $elements, \Text|string $separator, string $collator = null): \Text This would then allow stuff like: Text::join($someText->getWordIterator(), '-') to insert `-` in-between each word. ---------- 3. Inversely: Should \Text->split() only guarantee 'iterable', instead of 'array' as its return type? ---------- 4. How is equality comparisons expected to work? Will '==' be overloaded? Should users use 'compareWith(…) === 0'? Should an 'equals()' method be provided? ---------- Best regards Tim Düsterhus