Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110300 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 73122 invoked from network); 29 May 2020 15:51:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 May 2020 15:51:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F1F4A180088 for ; Fri, 29 May 2020 07:32:25 -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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, 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-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 ; Fri, 29 May 2020 07:32:25 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id z13so2853973ljn.7 for ; Fri, 29 May 2020 07:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=8Ijp1cSByGvzz1ysCqMnZgacSJBqDYbNXF1raIZDQAs=; b=k5/p2V7tFu/nkZs84Q/O7DERZfjqj66tj+ZSyhKpg/wE6L2ya3CqZlyFx9drr2StpF x3ieKvMVEURRNn0Py99YBvMbxxZCE2NGcX/mxvUYEqF9AeY2MKTICV/W9G4PBRfnRa0M Mnb5C9IAT0H4mfRHs09vfGTXQjKyjPJ4gpO2ymp47A9iPrjuwApQCL2Dvi0E1gaMKIRn qjiAIWpJzQXspA2FXSymU8sAeQA9NvzSK62wuU+k7KiJcGhGGjVLuLSG/ZYM2rwXI47p Su9glr6bS1E35R6CzBBpF1j9Ko8yxEKBuIerpouLish9lmh/jguPkWnI93u6gdZ8sNbx P7Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=8Ijp1cSByGvzz1ysCqMnZgacSJBqDYbNXF1raIZDQAs=; b=cg3f1OqVacmEKhbJtf8sFI1ddXg7K2FqyWlM8k0vJQWv3omiTlFTXTRztmN7OgC7c+ R2OnbsnO1VPslUOiu6do7kQxjrJRo0l61Mx1NIatMDAvERiUGOOCSDB+0EJR+ni17diS l0VOVi+PO9YWmroD7X3oYc9UN85GUnb4cvy7s5GJet003i0LHq70nHhLEDM75LQ5TW4B fZ1DfzeXkObz5zloqWwLht6MyPwvell50H+Sow1tFTVsqrpx7nNhxRMMRHoFQC40pzrp LPlqXOI0c9llmFMgq75QuOUFiO7BmURddjmV7PDducOCZBhcodO2hDepwbd3f0KGj4dj 5Qzg== X-Gm-Message-State: AOAM532rtNR8hcbNXBq0CGiDj8cjU608BP6WC2PoMnpSYFcMiqLQTWZL SOzKc43OnNfQYS4EH7ihcLeoL/BIuZV4GqTYgIAMPGkO0XiB8w== X-Google-Smtp-Source: ABdhPJx8/BK4TVvSevlVHyD7VNHHJ+S0YfluCGiYABLISWyP8Qhq55f/5Hn8ypxUUCGvrVuMvlZNxUsvyZjscr0TIfg= X-Received: by 2002:a2e:7c17:: with SMTP id x23mr4008297ljc.307.1590762741780; Fri, 29 May 2020 07:32:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 29 May 2020 16:32:04 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000025534905a6ca5077" Subject: Re: [RFC] Named arguments From: nikita.ppv@gmail.com (Nikita Popov) --00000000000025534905a6ca5077 Content-Type: text/plain; charset="UTF-8" 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 --00000000000025534905a6ca5077--