Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116600 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2973 invoked from network); 9 Dec 2021 11:03:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Dec 2021 11:03:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5643F1804F8 for ; Thu, 9 Dec 2021 04:03:48 -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.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, 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-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 ; Thu, 9 Dec 2021 04:03:48 -0800 (PST) Received: by mail-wr1-f45.google.com with SMTP id c4so9261155wrd.9 for ; Thu, 09 Dec 2021 04:03:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=flazalwx2SWKT1fePUnOKcer5FZvKlOZKbiRliFrNIs=; b=I3dXatOXGW/e5SO/PQuWnBvB/JsnsRl+tjJ3/QtuShysJHyJ5vzj4VNVTrT2RxLGyP YNNK+FA5GD11tOtWBDIKc2TTteCQt9KnGQheNiqre/ci1ztnJPstsE5J8plnXlvTAfFl rqQS3CVy4g4+STemjp606/B133TnHDB3VeMwMbols6nvqgt4b4Avh6QE2UuIlLqPO/bL HBBQipR2ri6IgYSzawxR3nrlO4MToQwvVSbWhrGmwHJB6FvC5kPr4gLZ+HaZJsp4CP3A JeDCcG4Z14YqN0YRb+l8c3YuTh+bkptHH/SLYdhz2SOSPX1jcOjm+owvd/yJ8nygBDWm 5qfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=flazalwx2SWKT1fePUnOKcer5FZvKlOZKbiRliFrNIs=; b=RUd5bx8sWQEN8CYY95DcP95f37b3ux2Z60VG3rOdcUIsPo+MzOcTtgm++Ajopgrkrb ncaML6lht8I3QpJkzxU/0ApUmMTjDUC119R8wAA4240t/3s+hIBqXhfU97TcQ/WxtR8L BQXxQ/oYAefHy380vuKyGAMZYej/NDQ1uvdSdM/mL0txVkcJcZFGcJwI6E0bC3jVLx1n 6ApyubTHDNqUZUQH8eTbFDYI2x+TDnFBWPKCSy49zwAXAIi4uX9dRVYUCKJDNHZdSA5z 2gMrLdJreCji2Yw1NS5bNjOUV9oiDEp0Aca17u4mraYKBwUwGWkmAXhBHj3rpvsgEZqD 0nFw== X-Gm-Message-State: AOAM533F3eMOHuYu1Uv4Be6Pn/5raGz5qQDcevyz7RBas5Q83GAmw4as QqdtTsJhYXm3iKdyKHzsV/XY+Mj3I9U= X-Google-Smtp-Source: ABdhPJxIeZYkfVuLmZ316RexJ9xDA5pmlpSCBbj8wasblo2r6LSLaaXiC3OYiUa9g8t8vWaa3cxv5A== X-Received: by 2002:adf:ea0c:: with SMTP id q12mr5843749wrm.299.1639051426576; Thu, 09 Dec 2021 04:03:46 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id j17sm6421342wmq.41.2021.12.09.04.03.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Dec 2021 04:03:45 -0800 (PST) Message-ID: Date: Thu, 9 Dec 2021 12:03:44 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Content-Language: en-GB To: internals@lists.php.net References: <02ba01d7ecbc$c0e13370$42a39a50$@webkr.de> In-Reply-To: <02ba01d7ecbc$c0e13370$42a39a50$@webkr.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Allow default parameters before non-default ones? From: rowan.collins@gmail.com (Rowan Tommins) On 09/12/2021 05:22, André Hänsel wrote: > If I try the same thing in PHP 8.0 I get a Deprecated warning and if I try > it in PHP 8.1 I get something that I don't understand: > https://3v4l.org/cg4DA There are two diagnostics showing in 8.1, the deprecation on the declaration, and a fatal error on the call. What's happened is that given your signature: > function blah($foo = "deffoo", $bar) { ... } PHP has decided it doesn't make sense, and re-interpreted it as this: > function blah($foo, $bar) { ... } Then when you try to call it: > blah(bar: "1"); You're missing the now-mandatory parameter $foo, so you get a fatal error. I'm not sure exactly why this behaviour has changed, and can't see any mention in the Release or Migration pages in the manual. It's not a *huge* break, because named params have only existed since 8.0, but it is technically a breaking change in a minor version. The only relevant discussion I've found is this, where Nikita is I think hinting at the new behaviour: https://externals.io/message/114007#114026 Regards, -- Rowan Tommins [IMSoP]