Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123191 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id CE5EF1A009C for ; Tue, 23 Apr 2024 19:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1713900264; bh=a8JffaoGQ/APBIHeA7RSVRGDR4KB/pEGLalwUxfhmkU=; h=From:Date:Subject:To:References:Cc:In-Reply-To:From; b=fkYQNANDkbaiPL4O5PqJe7VPX8ytZfw7kiqftDNlivdOEY7iB4+kkIOmHKxoAibiC 2TCyI7QCSA/w759/fKZZcbwfc5IGdqpWKGzPDDzCJA8pHBlIka95LWY4YsGHQYeIY9 yn9Y9VDQtCOhdILB0YENl5tQrlzVHEKdg+2ePEx2XKxuNLysvsD6ulBzduTHjfP7kM 6612OXCJrAe50ExvVVtSR9C+xI6RWcZSYRixdyVL2dlxGrqIFUy3SiPm1d9vxV5c5W TDM48G02k7IteWlnL4xlssJhnRukEbQ3nK8e6Kux/N6/pf8j4QpOnXLPwYRTu7jBnu bwrYXIkCCQg+w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8667618006E for ; Tue, 23 Apr 2024 19:24:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 23 Apr 2024 19:24:22 +0000 (UTC) Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a55ab922260so363475466b.3 for ; Tue, 23 Apr 2024 12:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wcflabs.de; s=google; t=1713900221; x=1714505021; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:cc:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=hJjca/P8f6VbBt+IUM3/ImxE8iArMoRw9vDakUyU7gs=; b=iD1oQvObgzh8p/EufWDqt09AyotdmYwm40pUfvSeZ9QbLKX//BqcIe9/7VvkV9UgAm r/GSs0wnZzkwFScoFbqC/o/dMaaIAEGeUiAF7/ZIes0ggaOYvSYNSTl1uBRzMSenOv31 o7iKgx4byyjbyMFveAVlsjdmuqYiF7K9mCVdKJqeAs9tJ/EvOp4hdJxmbIFOQwOUScIw yXlL4yhE4Y6W8jV/ol0KroF9eEt6SpJT6phvj8a0XGQF3XUsAprESHEQOQGbTLTIz4Or D9LgA6jviSseZ+dGocVHPtPF8m4yIW5dqpxpqAPTAfgl9aBqBxe+jk1NfY/cdGpXCA2R GDqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713900221; x=1714505021; h=content-transfer-encoding:in-reply-to:cc:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hJjca/P8f6VbBt+IUM3/ImxE8iArMoRw9vDakUyU7gs=; b=hlvZrlWMLkCy7hHspSwG+FwzW7sPyHyBbHHSnrTDnB0t+Nielh63GsYQVq6Hxvmx5J vh50c3u8HSMR/whCOYeQ3YFBgitQDQh5jNJuFuHvMjUfYnVq5xg1yFlr+9GgbJWUlJ0Y Dpny7ltXz+el4gMYqb92ALDL6k2bRmoEaeyQu/rPTq+d076ItmKbz5tILV63A6HMfmlv VQr8fyXQVSBndXSRclcxbVWSNmGp+G8WulN+SHd+1gcrjJk3w+KNJ75yGp8W7nRqecWi CUzKXeFst+FaL2X523lbFo/acNeUkvHDmUQVrhIWYyQ0wGD9uPnfaU+QIqO9Boh57UQD ND6Q== X-Gm-Message-State: AOJu0YzfGANQY2i1L09DmgjAAvWqzTm6YbGl4wx9JcpDGgB46JSJiFQv rnsMn+RVKwD0NMqLimEcebzczaTjZ10N+EhpkTDpLjCV6brcFKFTkqULFYesfNGcJYErInkdQRP QMtbSww== X-Google-Smtp-Source: AGHT+IHcW8S20S4OHjORXpceNifL8zCY53zEekZ9GX2dP8Ts1UI0ODKDG2fsX0EoflxwRo/pSlfgnA== X-Received: by 2002:a17:907:984c:b0:a55:b2da:3cac with SMTP id jj12-20020a170907984c00b00a55b2da3cacmr186946ejc.10.1713900220317; Tue, 23 Apr 2024 12:23:40 -0700 (PDT) Received: from ?IPV6:2a01:598:c000:4af0:c84e:88f0:939:200d? ([2a01:598:c000:4af0:c84e:88f0:939:200d]) by smtp.gmail.com with ESMTPSA id wr12-20020a170907700c00b00a55acd765e5sm3531282ejb.160.2024.04.23.12.23.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Apr 2024 12:23:39 -0700 (PDT) X-Google-Original-From: =?UTF-8?Q?Joshua_R=C3=BCsweg?= Message-ID: <6dbe2789-d256-4420-9a41-59459291a4a1@wcflabs.de> Date: Tue, 23 Apr 2024 21:23:38 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] RFC [Discussion]: array_find Content-Language: de-DE To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , Larry Garfield References: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> <278889be-82ab-4827-a9e7-801b5ba2d8f8@app.fastmail.com> <45b726f4-8085-43e2-b701-6b35bc249409@wcflabs.de> <2dd7ef64-d1c5-4ed8-964f-b86dba110e0d@app.fastmail.com> <4bdc94d9-f35b-423a-b3a7-1a91fbf48424@app.fastmail.com> <886bea6f-20a3-4f20-b773-7204a83a42dd@bastelstu.be> Cc: PHP internals In-Reply-To: <886bea6f-20a3-4f20-b773-7204a83a42dd@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: josh@wcflabs.de ("=?UTF-8?Q?Joshua_R=C3=BCsweg?=") Hi On 19.04.24 23:17, Tim Düsterhus wrote: > On 4/19/24 22:08, Larry Garfield wrote: >> There's another issue, though: Will the callback always be given both >> $value and $key? > > The current implementation always passes both, which, as I just learned, > is inconsistent with `array_filter` which has the `$mode` parameter to > control what to pass to the callback. > > Not that I claim that the `$mode` parameter is a good idea from the > typing perspective for static analysis tools, it probably isn't. Yes, this method always passes both parameters. This has the advantage that we do not need a third parameter that specifies which parameters are to be passed to the function. The `array_filter` method was developed at a time when there were no closures and it was therefore not trivially possible to change the parameter order of a function (or to omit a parameter completely). With closures, this is now possible without any problems. Converting the method so that it works like `array_filter` would mean that we would have to introduce new constants (or inconsistent, too: an enum) for the function that controls this behaviour. Reusing the constants which are used in `array_filter` is not possible, because the constant name contains the function name `array_filter`. Cheers Josh