Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123252 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 185081A009C for ; Thu, 2 May 2024 13:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1714656516; bh=6N2PuDlWZg5Qb91djNTW1q8d87iefTUc9f2tVgzAWHU=; h=In-Reply-To:References:Date:From:To:Subject:From; b=YHL2IPHTLUv0+/X+hCuWyZ37VQCoyErbUfoj4RPdcgk4qUG0L2niWBSy1O8X/LHUr JnFHVHn6t31g8/F+1JpYsgWYisgxVAobp5lMJGvc+xn1UzPbdI2ir0eVq4m9xMwalX SdxkS9/QmodQ6wX/YR4FnIVxdL1bCj7wnLsbYMRK5xVBN/Ec5x8hTsXibvJx1ZHJLy St+g2DjKgQcvgiWHLOWT60TVE2IZaTkynqvT6hEL6tu5oSoJIof7JvZL7DGdaGUgya o3PBwo41iCZsMSfYGLBQmup++FuzEPdUYxTd0uOZFgViT27sYPKl0xoReUm2zXhalw 5RMzpaHCWLfGg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1A6D0180078 for ; Thu, 2 May 2024 13:28:36 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout8-smtp.messagingengine.com (fout8-smtp.messagingengine.com [103.168.172.151]) (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 ; Thu, 2 May 2024 13:28:35 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 1FCD21380091 for ; Thu, 2 May 2024 09:27:50 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Thu, 02 May 2024 09:27:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1714656470; x=1714742870; bh=eoZsFp39yfxbJ4vnDMxQS F5q2vL2xrcPfD26JkeyW0s=; b=dpgMaYB4O7gHCTni1m/iauiAA8AMi9+4Mfn1T jFXJbmo6rqb7ekSOcsSJ0AJodwiqvU3lC2kLmK4mz5BUtZ/8D3FedWRxasAmT2re l4kpTGpG9RcD1AN3We05RkLmHUCNqk5yd6TSXatFU68cjXeUxCNmbWuYV7KMid3s Coa4AFOpIiKno7Cph/APpl9IzOHdgsAUW0rL0/phZtBRwUFSL/t8Daj7w0xgaeAY nRJuDAuV2OMbR5SDuyzAncds6MVSGxtAHGclctMdlR6Xz+pdOY24TxAKrcAwdT8x pHG7BiK4s5ZzndyWUHgQ8YdhYluvJMhqc8/rY4df/XNLrQCUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1714656470; x= 1714742870; bh=eoZsFp39yfxbJ4vnDMxQSF5q2vL2xrcPfD26JkeyW0s=; b=K X2rLqNstlBRNC013lGp/W756kRPiyuEjBRhRozAoP+srGXsMoQDd7uidmaoF1+OB 8njMrfPCQzhcjkMP0hFsx23yQrLAlkpWpOBBu+m7b0CxNoU7bVYEuySsghHIMONg ycaZbMwAxc09AoOxJh7Yg3ZqCH2Oc5RG+A4TL6G9RwoaGWnEduTMqNiC+WE9zAIS CCld03ESL787e2TvvoNsY5QOkkGPl1oTcK1z6iOIac+jRiEhzTOtXTh+7Z54CxEJ qdQtbned/rnq29TB6QM6bZO2iLRHvilfFbrHhG2uhaz2yuZwOPsSP6pU3k8drWiv +2lNdjxyXJsI/UkjqvkqQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddukedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhephfehtddtiefhteelffevudegueeihfelfeduueej feevveefheefteevvdeukeevnecuffhomhgrihhnpehphhhprdhnvghtpdgvgihtvghrnh grlhhsrdhiohenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 90942170016D; Thu, 2 May 2024 09:27:49 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-416-g2c1796742e-fm-20240424.001-g2c179674 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <7a77288e-ddb7-436e-8981-b8b2508e1547@app.fastmail.com> In-Reply-To: <41ad56d9-8b27-420e-ba85-a3e9a6122bcf@wcflabs.de> References: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> <278889be-82ab-4827-a9e7-801b5ba2d8f8@app.fastmail.com> <06373f2b-5de0-4582-96c5-29c3b474c01d@wcflabs.de> <45e6365b-4963-4969-8cc1-80bae6922fc8@wcflabs.de> <60bb55a5-16c9-4df0-8521-75f82d3dbf5b@app.fastmail.com> <41ad56d9-8b27-420e-ba85-a3e9a6122bcf@wcflabs.de> Date: Thu, 02 May 2024 13:27:29 +0000 To: "php internals" Subject: Re: [PHP-DEV] RFC [Discussion]: array_find Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Wed, May 1, 2024, at 9:26 PM, Joshua R=C3=BCsweg wrote: > Hi > > On 01.05.24 12:26, Larry Garfield wrote: >> This looks good to me, with one remaining exception, which isn't spec= ific to this function but should still be discussed: Always passing the = value and key to the callback is unsafe, for two reasons. >>=20 >> 1. If the callback is an internal function rather than a user-land on= e, and it has only one argument, it will error confusingly. That makes = the current implementation incompatible with unary built-in functions. = See, for instance, https://www.php.net/is_string (and friends) > > I think, that this problem can easily be detected with static analyser= s.=20 > Currently neither PHPStan [1] nor psalm [2] does detect this issue, bu= t=20 > as the tools already validate the signature (e.g. str_contains is=20 > rejected) this can probably be integrated and might even be considered= a=20 > bug. > > The proper fix from PHP's side would be something like the proposal in=20 > https://externals.io/message/122928 (RFC idea: using the void type to=20 > control maximum arity of user-defined functions). It's not just that it errors confusingly. It's that the design as is wo= uld be incompatible with any C-based function. A function that works wi= th anything *except* the standard library seems... problematic. It's possible that, since these new functions are C-based, we could do s= ome extra detection to see if the function is unary or not, and pass onl= y the value if it is. I don't know if that is possible to do performant= ly in C, but it's definitely more of an option than if they were in user= -space. (Again, I don't know if this is the best solution, but it seems= like a possible solution.) --Larry Garfield