Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119402 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68893 invoked from network); 23 Jan 2023 17:24:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jan 2023 17:24:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 308FD18054E for ; Mon, 23 Jan 2023 09:24:26 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 23 Jan 2023 09:24:25 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 50F765C01D9 for ; Mon, 23 Jan 2023 12:24:25 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Mon, 23 Jan 2023 12:24:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1674494665; x= 1674581065; bh=RNCR4iiLVYlTCWuR1wqojOFyw8avf6FKC8X24+vgJBI=; b=D OKI9kvwFHMMFgc7e3UR3f9VyS4gl1v4bblU53TAxr4G0yMrbwLT0abmZfI90kQWW TcvOVE0UZn3/tSL9cia+NFJ5Pwb3b6+zcMzixmqCaIfFlwLSpEcmeDdZkaUTKQug 1x0yvHWqgU4fBzTwnj3TfCyn7E6NzAFFBWMEdsDXiXFV/fVZH+3eBM8y6SSvzuBQ Pq1lZwyyfteLrkcpPxC3B5ZGqFBo3L6dJ/agwrmbx6sq+fo1l7dQqaTYCLBdyXqo eMZmpdhFC5M4fbXqI1sWLOyqjNvLhM1FJaIM45MpAmCG4+gHx3PKNUYhO2t1w7UA A646s/ovyes0xI2BhfbFw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1674494665; x=1674581065; bh=RNCR4iiLVYlTCWuR1wqojOFyw8av f6FKC8X24+vgJBI=; b=p1avOBMCrGhoD2sNcoWyODkEOvFH6BRfMedKP7wPhCth 9I0pZsk9vU56Ixu+jymXom+HQekKjohrpARFSawpkChZ82NkHcIEUIILNshyAntw Ii7viyjUAXwtUUJsATJ7145J7cdNjLcx99iFTZZspcPupYMjNCEboSZtIY3M/xHT 1vQo9/h8YZbhdvqlsgN4mLI0gEePOLuillmz3Lvfh+YCsDDWalCW7cO1fnm8hr6X s9fyHA1tllX0v5UnCUwoaZSmFSS5qYA1Z0Jv9IjuCroAbR8DPDzJ6wCN9UZqPnFk /muviahDk5g9OMj8w/sBtZP1VWFhbu+jn5B42uLlIQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddukedgkeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0987C1700089; Mon, 23 Jan 2023 12:24:25 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-85-gd6d859e0cf-fm-20230116.001-gd6d859e0 Mime-Version: 1.0 Message-ID: In-Reply-To: <99bc38dc-3d62-4a1e-a99c-e5daab3d779f@app.fastmail.com> References: <8f530a4a-bf48-4259-877e-16ebf8082936@app.fastmail.com> <88a59c46-9261-43f1-874d-ffc2f9caff32@app.fastmail.com> <99bc38dc-3d62-4a1e-a99c-e5daab3d779f@app.fastmail.com> Date: Mon, 23 Jan 2023 11:24:04 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Introduce the abiltiy to use the first-call-callable syntax on non-static methods, statically From: larry@garfieldtech.com ("Larry Garfield") On Mon, Jan 23, 2023, at 9:39 AM, Ollie Read wrote: > You are absolutely correct. I guess the solution would be to handle it > differently in this case. > > Creating a closure from a static method would be fine, as it creates a > static closure, but when attempting to create a static closure from a > non-static method, it would instead return a closure that errors if it > isn't bound to an appropriate object. You'd most likely want to > restrict this to public methods only, which would help with the > security issues. Then don't make it a non-static method? Using an object method as a static method has been bad practice for as long as I can remember and an error since sometime recently, I think, so let's not do that. > There's already a check there that throws an error, so we can already > tell the difference there, but the tricky part will be in the returned > closure. Perhaps something like "BindingClosure" that throws the static > error when attempting to call it unbound, or better yet, a more > descriptive error about it requiring binding. > > Would that be feasible? By the time the error is thrown is too late. It's a distinction that needs to be made before the bind. So you could do like: if ($fn->needsBinding()) { $fn = $fn->bindTo($o); } (Or something.) That said, it sounds like you're talking about something different anyway that is probably unfeasible. Also, please do not top post. --Larry Garfield