Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114026 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74771 invoked from network); 12 Apr 2021 09:47:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Apr 2021 09:47:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 960E71804DA for ; Mon, 12 Apr 2021 02:48:13 -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-Virus: No X-Envelope-From: Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 ; Mon, 12 Apr 2021 02:48:13 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id o16so14603268ljp.3 for ; Mon, 12 Apr 2021 02:48:13 -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 :cc; bh=45OoEoGef6qh5mrU19dbM8TSlJYWzhoSRywvW+0tnKA=; b=P2ZT2UfHdK9W7fTaJrRJAJ9H/2L+YlhxagIexY4fTpw0eBIJYmkdIQfq/oe1N0eQSQ hMJRTnkXRllCF+U0iIrj/Js9IiUKgah/0KjadOSQlYPUzl8yNMicnjfNWqlGubgCvfAp uP5hlscki8oaq4B1sHWC6TNl0F4AZnxmqi2SUoX0lDNrb/PkxKBws1yremPt8wamYxf4 +AZpBYs1I7AwYtCFulz8eIHQQ28U1eYH8JF7SakTeXjNkMTg3ZmbEMa18u68y2TL2rUe ckbQo2ZeePQssxCpZzV3h68oRITLY0mvOLP2eOvk5QJey/WhhfXpBTEvra98WIeL5xWJ E5xw== 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:cc; bh=45OoEoGef6qh5mrU19dbM8TSlJYWzhoSRywvW+0tnKA=; b=sadS+aXHoPygM2WRCqc4BPLeNUxN0ON30UUFuzhwV8D2JijAu8BeEDqOlXpbX3LZJE 6ugX1O1haZqdGCfa3R3RT/YZ2IcRFPztowR8epic4jDjHGyqxidByGiboBcs0YTYUJmb /aQogF2yOPAKdvFpZGyoY+Iu+6e5gyBQdtObEnu+aLjixb+jVhXJljqp9+6Kse2tgFxQ wCoUlY0xR5OY05BKsnOkeCCtHyRR6TBmKuM5nY3uxq4IJlO8Xb1+zUwgxcChOr/4ckdY 8jk192HBL2HD3EOhTy7ja3P7haYHBnH7VGEwUgPVvwKV5AKi5y3TV/Y5JF3a6UwY6ShQ iKDA== X-Gm-Message-State: AOAM5308gZcPfFmIPFqoIZ84cGxooUiJZ0dHa9myhMytWcqWqKdQV1Ii 9YYovpAzc9nalLtYFjX9DfF1NraoXKvlDoyV4Zc= X-Google-Smtp-Source: ABdhPJwAaPIH12awNY0hhtuhLq8ZVrS3zqG+IUKO3uz/ZOxhMJr++GFBL6Js4nfLXoH5x/EZbk9Xv1Q958rY5h62ZdA= X-Received: by 2002:a2e:9082:: with SMTP id l2mr1576730ljg.272.1618220891573; Mon, 12 Apr 2021 02:48:11 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 12 Apr 2021 11:47:55 +0200 Message-ID: To: Benjamin Morel Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000690fca05bfc36900" Subject: Re: [PHP-DEV] Required parameter after optional one From: nikita.ppv@gmail.com (Nikita Popov) --000000000000690fca05bfc36900 Content-Type: text/plain; charset="UTF-8" On Fri, Apr 9, 2021 at 9:24 AM Benjamin Morel wrote: > Hi internals, > > I'm wondering why PHP 8 started warning about required parameters declared > after optional ones, when this version is the one that also introduced > named parameters, which can take advantage of this: > > ``` > function test($a = 1, $b) { > echo $a, $b; > } > > test(b: 2); > ``` > > > Deprecated: Required parameter $b follows optional parameter $a in > /in/DmhYG on line 3 > > 12 > > https://3v4l.org/DmhYG > > If I'm not mistaken, the introduction of this warning (January 2020 > ) predates the introduction of named > parameters (May 2020 ), which could > explain why it would have temporarily made sense to introduce this warning. > > Shouldn't it be removed now, that it makes IMO full sense with named > parameters to have required and optional parameters at arbitrary positions? > I'd say it's the other way around, and named parameters are at fault here: We should not be allowing that call. We should probably explicitly drop such default values during compilation (which will change reflection output though). Nikita --000000000000690fca05bfc36900--