Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110836 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45144 invoked from network); 3 Jul 2020 15:46:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jul 2020 15:46:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 804191804DC for ; Fri, 3 Jul 2020 07:35:56 -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=-2.1 required=5.0 tests=BAYES_00,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, 3 Jul 2020 07:35:56 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id f5so21377395ljj.10 for ; Fri, 03 Jul 2020 07:35:55 -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=MrKdBbulGZpPY9oz9oerj9Z10S6pT6TDCLKtq4GVy2E=; b=meielNIrrkOtD4e6ZEF/cIEv7HPnI886wKMk1XHZdgYFqY37KrlZKV/QuNR118i96u DYV8mCiRknEVtDt6a7dIYlWVKctBI3uxzJheUAJbI4ZFv+O5zxW9AjUojw4fEAwv1pwn uW9iS5J+IYge6EDFgwsENCD3bij5+NnROtEtyzIRIrzQYmc/aeB774QQ8AQWtdG5eGCJ YDUktH/dG459omuNiAgv6kNC3O7vpVmzVMVMp8bh3j7r3JaJssGATnswXg3wUivH0pep SXTSvkp+G3PeKLqK3ixF0KRnclltLAujlr5UClGkMcxAOlmkqesoOdY+1Zg4TmyvVlw5 yYrg== 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=MrKdBbulGZpPY9oz9oerj9Z10S6pT6TDCLKtq4GVy2E=; b=qinJOq4LspwTnLmkcW/pIydHj092I9nWmBTcgwDeaYhuQFrH2Eg8esEvnOVT0PNkn/ XImsYjj3BtrnY6I0+O+l2+ZzoRzvw6e8t9OR9SujvUnrRJVT06zr4vlS9TmtEmmvWDf6 Szam6jcYGK/k4dyvLe4a62RIxlJn4wv8/YcDTUkWvHNOt9wKfd4TpfaJdKEZdoOCvvcj X7g8FKe5vf2oiOWzL45OYgpoJa+k9DxkJHO090ppf4MQI+IGcxDaVrN8Ik8qZLy1V035 G0xVMQd8EetHTRfvGSa7n6QXX23Lw+3TSG002NERd8vVeCGmQmja9vt9uKR9b1bINu5h Nc6w== X-Gm-Message-State: AOAM533JwUxOqqqxmqrm2OSDEB1EAIfdhtbmWZCMU6LSMcv0v42N1p2f huXU1gq8U2w/EfOG9QYYQbz/MNtnrIw7fTcGb/Jks6H/Ifc= X-Google-Smtp-Source: ABdhPJzUoZrQaqrK9NgXrA/J0VqAwX1g/U4RHH46en6tB/5o+V4vWhzPKlbD64FMdMC1+j+zJQgRHXTUSrXjkCOSn3E= X-Received: by 2002:a2e:6e05:: with SMTP id j5mr19495258ljc.135.1593786954338; Fri, 03 Jul 2020 07:35:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 3 Jul 2020 16:35:38 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000042d55305a98a716f" Subject: Re: [RFC] Named arguments From: nikita.ppv@gmail.com (Nikita Popov) --00000000000042d55305a98a716f Content-Type: text/plain; charset="UTF-8" On Mon, Jun 29, 2020 at 5:13 PM Nikita Popov wrote: > On Tue, Jun 23, 2020 at 12:10 PM 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. >>> >>> Regards, >>> Nikita >>> >> >> As we're moving in on feature freeze, I plan to move this proposal >> forward soonishly. >> >> I have update the RFC to drop the syntax as an open question (I haven't >> seen much opposition to the use of ":"), and to describe the possible >> alternative LSP behavior at >> https://wiki.php.net/rfc/named_params#parameter_name_changes_during_inheritance >> . >> >> While writing this down and implementing it, I found that this has more >> odd edge-cases than anticipated. Overall, I'm not sold that this approach >> is worth it. It sounds nice on paper, but I strongly suspect that it solves >> a problem that does not existing in practice, and will force us to keep >> this patch-over mechanism indefinitely, while the real solution would have >> been to fix the limited amount of code that is in the intersection of >> "renames parameters" and "is actually invoked with named arguments". >> > > Just as another reminder: I plan to put this to voting by the end of the > week. > > I've also updated the RFC to make the LSP behavior a secondary vote. I'm > not convinced this is a good idea myself, but some others seemed to prefer > this approach. > I've made two additional changes to the proposal: 1. Explicitly mentioned attribute support in https://wiki.php.net/rfc/named_params#attributes1, and added it to the implementation (oops). ReflectionAttribute::getArguments() will also return named arguments to the attribute, and ReflectionAttribute::newInstance() will behave in the intuitive manner. 2. Added some information on internal APIs in https://wiki.php.net/rfc/named_params#internal_apis. The tl;dr is that named params are pretty much completely transparent for normal extensions, but there are some additional APIs if for example you want to perform a named param call from an extension. In relation to this, I'm also considering to change the semantics of call_user_func_array() to treat array elements with string keys as named parameters, rather than simply ignoring keys. The motivation here is not so much call_user_func_array() in particular, but various other APIs that do the same thing, such as ReflectionMethod::invokeArgs(), which should all behave consistently. Relatedly, I'm wondering if something like this should be allowed: call_user_func('strlen', str: 'foo'); I'm leaning towards "yes", in which case call_user_func_array() should be also be treated consistently. Regards, Nikita --00000000000042d55305a98a716f--