Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108404 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 48429 invoked from network); 5 Feb 2020 11:37:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Feb 2020 11:37:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B62FD1804D1 for ; Wed, 5 Feb 2020 01:49:56 -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.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-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 ; Wed, 5 Feb 2020 01:49:56 -0800 (PST) Received: by mail-lf1-f52.google.com with SMTP id n25so1033611lfl.0 for ; Wed, 05 Feb 2020 01:49:56 -0800 (PST) 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=0a4dutDpJ9r//t3AwnR5UNNesQ6r2ox+RVzpNT0badI=; b=igQCL8wY4LHb4GBvtUiAa1VfXKE8YcZdpCiJVfWHpqciiIKTErEr7XbYUuhyLmcnPl 9jPLUKSJzOH5kZL8t6eC+wGcegADwyqR7fOpEfqdN/btASHU7SWuYQrsfoUM5X1ZFpJv Zyf/eQaHrfFOVzf7eY6+ZgCgCY1jusw3OygyU5Ihs9OmsprFK8l9KIQOoObr5xtCZvvp WN9bHFhTHaqG0VWjUVqZAWB4Cz4oTPkCr9Ld7PPSwR1feNNLgAz+UxJwiwt25Zwt181U zqOEVfLpd3W6+Tha41Qxziz9NpZRcwWQ3Ay/q7K/ynwdB66hPpqPlcavgKsYbuTIycyp Infg== 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=0a4dutDpJ9r//t3AwnR5UNNesQ6r2ox+RVzpNT0badI=; b=SCQgLjSeMyn5H77i4CMgM23wSACyqwNqFnNsHxxPIT/yGuSwmjH0KakIBb5opZCqng LR3wpShc2NtNY94QioBs8R9vvoprZSNU8gyVr4OZgQHd4+gBwUDkwF432/egWAt3l7K0 hwfTVdkHg2D3H+7NevNQU/JnJKoSeSVFsB6FJWe2ZVpHJdZQ2Cn/bGvdaF1AXlt/BnyR teFZ7pjTFT3TyQfmSiJswq0sSXFOyjR2t8AhQNaCROXwgx8y74ZbqRfILRO7zArBpssj ZACGcCwENMDV+SKRRBV7KVvcJzm0KmHbDEejcr2FwO4FFDdzhnZ69K3Ml0A+A54/sDH/ kWzw== X-Gm-Message-State: APjAAAVDxyGPbxICA3ZUFK1oU0VSkYuRm/MgJjBpS19brv5DSEFRaUeb lTvwJvS8pBWHKWIDQGy8TkWZnfltR3fa9DJ6Y+Q= X-Google-Smtp-Source: APXvYqyEZi+KVwqk5KzW/Y4pPfvjeF7w+LxE5DCiF2F75w6+5OVyt6Lt4JwgX6nkB0j3rwr8Y+t0MGRoS/tt4TBpEhI= X-Received: by 2002:ac2:5e29:: with SMTP id o9mr17498673lfg.81.1580896194594; Wed, 05 Feb 2020 01:49:54 -0800 (PST) MIME-Version: 1.0 References: <5e24c6ec.1c69fb81.1d93b.aafcSMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <5e24c6ec.1c69fb81.1d93b.aafcSMTPIN_ADDED_MISSING@mx.google.com> Date: Wed, 5 Feb 2020 10:49:38 +0100 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000001b0be8059dd11450" Subject: Re: [PHP-DEV] Re: Warn when declaring required parameter after optional one From: nikita.ppv@gmail.com (Nikita Popov) --0000000000001b0be8059dd11450 Content-Type: text/plain; charset="UTF-8" On Sun, Jan 19, 2020 at 10:15 PM Andrea Faulds wrote: > Hi Nikita, > > Nikita Popov wrote: > > > > Since nullable types have been available since PHP 7.1, having a required > > parameter after an optional one is increasingly likely a bug rather than > an > > intentional workaround, so I think it would be good to throw a warning > for > > this case. > > > Wouldn't it be trivial to special-case `= NULL` here to not cause a > warning, or to cause an E_NOTICE instead of an E_WARNING? That would > make this less annoying for old code. I don't know whether I think this > worth doing or not, I just want to point out the possibility. > I like this idea and have updated the pull request to ignore the "Type $param = null" case, so the deprecation should now just catch the "definitely" incorrect signatures. So to summarize the current state: function test($foo = "bar", $baz) {} // Deprecated: Required parameter $baz follows optional parameter $foo function test(Abc $foo = null, $baz) {} // No warnings, works fine! With that adjustment made, are there any further concerns about this change? Regards, Nikita --0000000000001b0be8059dd11450--