Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116597 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82996 invoked from network); 9 Dec 2021 04:21:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Dec 2021 04:21:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B43C81804C4 for ; Wed, 8 Dec 2021 21:22:31 -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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 78.46.0.0/15 X-Spam-Virus: No X-Envelope-From: Received: from mail.webkr.de (mail.webkr.de [78.47.173.34]) (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, 8 Dec 2021 21:22:31 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7EFFF1A279A for ; Thu, 9 Dec 2021 06:22:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=webkr.de; s=dkim; t=1639027348; h=from:subject:date:message-id:to:mime-version:content-type: content-transfer-encoding; bh=q0tBHgAJLAb4DIQW95vHlENc44l1JW7WnWADWS+wbFY=; b=UKDuQJpxPLpw2ezwZFmZ6YY1dqs2ZTNwWF8lqYa/hbbDmMrLyImEVGNcwikv5t4XL5YD00 s2vDNMm5eXY1c4xR2k3PpfWeAGQYHWhJn/N7iIzmPicLugYS79tfp9UcrYvYOgbZa9++eJ HdWBZUkjSW46RInDzQ4xod9+PGIzhcc= To: Date: Thu, 9 Dec 2021 06:22:24 +0100 Message-ID: <02ba01d7ecbc$c0e13370$42a39a50$@webkr.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Thread-Index: Adfsu5/0WUzIcZExRt27v087U5CkWg== Content-Language: de X-Last-TLS-Session-Version: TLSv1 Subject: Allow default parameters before non-default ones? From: andre@webkr.de (=?iso-8859-1?Q?Andr=E9_H=E4nsel?=) PHP 8 has named parameters in function calls, Kotlin has named parameters in function calls. Kotlin has this handy feature that you can put parameters with defaults before normal ones. Those parameters can then only be used by naming them. See also: https://kotlinlang.org/docs/functions.html#default-arguments This is very useful because I can add an optional parameter to a function and prevent users of my function from using the parameter in a positional way. This way I don't have to make a compatibility promise to never change the position of this parameter. 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