Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110303 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19940 invoked from network); 29 May 2020 20:21:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 May 2020 20:21:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 90F1A1804E0 for ; Fri, 29 May 2020 12:02:34 -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=-1.2 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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, 29 May 2020 12:02:33 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 663FC5C0088 for ; Fri, 29 May 2020 15:02:33 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Fri, 29 May 2020 15:02:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=VzhCH1 kkm3fK2qEauinH42CTcgZejAjV2I9bT1rZchc=; b=1Ue6OxiZsXkq5R64j9dg7r Ygxl2zMUH8uXQE85OBsNzgBeCvYDUQ6noZGADkuPXg2IOkAkZRnLZTtPRh5Y1F5F oFFFSmuBo+9ehzgx3LTxezHI2s5HPbLERay7CfU4Y6pESb7GGp9gKu1wY2Vix+R1 lDfUit5+giFnMEJq1/Ndojo/eSMoAdGgVaT86Xz/R93HNVMy1vYpX30JQfto6uyr UoVmcDGgd/SELAgAlIDvNEOWWdWAbphaoXw7L21I/3Q9ZolxPQVuY4wvY519/TB0 XCO2Az8F271QvQqob3prMclI5jpVDgEME6CunwSqMXo+zFttYDfG+x6vqigKDCGA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddvkedguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepudehteettdetheetieehudehueekleejgfdtledt gfdvffeuveeiudffffekudetnecuffhomhgrihhnpegvgihtvghrnhgrlhhsrdhiohdpph hhphdrnhgvthdpghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id D998A14200A2; Fri, 29 May 2020 15:02:32 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-dev0-504-g204cd6f-fm-20200527.002-g204cd6f2 Mime-Version: 1.0 Message-ID: <6f10d1a9-f523-42de-943c-4e9d38f9fffa@www.fastmail.com> In-Reply-To: References: Date: Fri, 29 May 2020 14:02:11 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Re: [RFC] Named arguments From: larry@garfieldtech.com ("Larry Garfield") On Fri, May 29, 2020, at 9:32 AM, Nikita Popov wrote: > On Tue, May 5, 2020 at 3:51 PM Nikita Popov wrote: > > > Hi internals, > > > > I've recently started a thread on resurrecting the named arguments > > proposal (https://externals.io/message/109549), as this has come up > > tangentially in some recent discussions around attributes and around object > > ergonomics. > > > > I've now updated the old proposal on this topic, and moved it back under > > discussion: https://wiki.php.net/rfc/named_params > > > > Relative to the last time I've proposed this around PHP 5.6 times, I think > > we're technically in a much better spot now when it comes to the support > > for internal functions, thanks to the stubs work. > > > > I think the recent acceptance of the attributes proposal also makes this a > > good time to bring it up again, as phpdoc annotations have historically had > > support for named arguments, and this will make migration to the > > language-provided attributes smoother. > > > > Regarding the question of what to do with regard to LSP validation and > parameter names changing during inheritance: During internal discussion, > the following option has come up as a possible compromise: > > 1. When calling a method, also allow using parameter names from the parent > class/interface. > 2. During inheritance, enforce that the same parameter name is not used at > different positions. > > This ensures that renaming parameter names during inheritance does not > break code relying on parameter names of the parent method. At the same > time, it prohibits genuine LSP violations, where a parameter has been moved > to a different position. > > I've run some static analysis to detect cases that would be affected by the > latter check, with these results: > https://gist.github.com/nikic/6cc9891381a83b8dca5ebdaef1068f4d The first > signature is the child method, and the second the parent method. I did not > put in the effort to make this completely precise, so there's both false > positives and false negatives here. But it should be enough for a general > impression. And the general impression is that these are indeed legitimate > LSP violations. > > This approach would be an alternative to either silently ignoring the issue > (as the RFC proposed), or to warning for all parameter renames. > > Regards, > Nikita Just to make sure I follow what you're proposing, given: class P { public function foo($a, $b, $c) { ... } } This is legal: class A extends P { public function foo($a2, $b, $c) {} } // Mean the same thing: $a = (new A)->foo(a = 1, b = 2, c = 3); $a = (new A)->foo(a2 = 1, b = 2, c = 3); This will parse error: class A extends P { public function foo($b, $a, $c) {} } Am I following the intent correctly? If so, that sounds like a very reasonable and safe middle-ground. --Larry Garfield