Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116055 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 26787 invoked from network); 17 Sep 2021 04:07:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Sep 2021 04:07:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 11FCA1804CF for ; Thu, 16 Sep 2021 21:47:11 -0700 (PDT) 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,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 16 Sep 2021 21:47:10 -0700 (PDT) Received: by mail-qk1-f175.google.com with SMTP id 73so8589714qki.4 for ; Thu, 16 Sep 2021 21:47:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xz4xmDuXgY3rP48MTq5THGbCO6Frvf/UWpLvjwfHUrE=; b=VPTuQ/PzJnq6LiSYbP5zceS7wD7s8PUacTSJIgOlOC37XoRi/e4FcVh90AKh0gf4Z2 jPAIxlR1Rirr9pCBrkfdYHIRP1XLS1DMKSjESm806hwWSiGmbFs6BN8e+njRmNfrHH7/ wv8BifPS+dMpp8jOkG7E5sjVLY1z/B8yzY7dU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xz4xmDuXgY3rP48MTq5THGbCO6Frvf/UWpLvjwfHUrE=; b=nl9c7iTCS5RMqEQhsSk5DbsEq7f/G1KQyHEd3US/cbCZkOZ0OTwA+HTWTht4MTECZL MHn4lEVmCSEIfhoDxhAwqXT/2RODe0/Fd8fFJoI6v0tZnntadfjfODKmCYy9Ris3AFWw olSOC5JZCaHQ+KWOrIY9mHr1qJu5OCPN6bl75fJAaIAtvG5DUxURCHxVAVSnP3yybJYP Yt+K2u2ql7UuiijLyAATQXGLnB6/2WSrDf0EFl0hShAduGfapu8RfL1KypPiVYUN+s3A y3JJFkQL0mFWVvImIk4vJ+rEza3OD1+L5cmbHvvkCVxwYtUAAHKf6OvQsk55rWFEaUVe zxAA== X-Gm-Message-State: AOAM532IYNGK9JZ7Ci12S7/BzAMTuVOoJ8EWxWycDN5d1N6/fd2FXFVn 5AfEZ3H3gE1ZSTRe3j8txaq8NU2WbpiAz8zWltg2Sw== X-Google-Smtp-Source: ABdhPJwqvBNmQ3q4yvJwikFzXsgh8xuiIFEsLqL+N7Y0begg8poC0/ZtGcGemSrMidMOBgY/lNbbpFbdhvTMkgwnXFs= X-Received: by 2002:a25:47d7:: with SMTP id u206mr11739379yba.537.1631854029841; Thu, 16 Sep 2021 21:47:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Thu, 16 Sep 2021 22:46:59 -0600 Message-ID: To: tyson andre Cc: "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] RFC: Add `final class Vector` to PHP From: internals@lists.php.net ("Levi Morrison via internals") > > - `contains` also doesn't have a comparator. > > I was considering proposing `->any(callable)` and `->all(callable)` extensions if this passed. > I'm not quite sure what you mean by a comparator for contains. There'd have to be a way to check if a raw closure is contained. I mean that there isn't a way to provide a custom way to compare for equality. One way to accomplish this is to have a signature like: function contains(T $value, ?callable(T, T):bool $comparator = null): bool The same goes for `indexOf`. > > - I don't know what `setSize(int $size)` does. What does it do if the > > current size is less than `$size`? What about if its current size is > > greater? I suspect this is about capacity, not size, but without docs > > I am just guessing. > > It's the same behavior as https://www.php.net/manual/en/splfixedarray.setsize.php . It's about size, not capacity. > > > Change the size of an array to the new size of size. > > If size is less than the current array size, any values after the new size will be discarded. > > If size is greater than the current array size, the array will be padded with null values. > > I'd planned to add phpdoc documentation and examples before starting a vote to document the behavior and thrown exceptions of the proposed methods. I would rather see multiple methods like: function truncateTo(int $size) function padEnd(int $length, $value) // allows more than just null function padBeginning(int $length, $value) And one or more for increasing/ensuring capacity without changing size.