Allow default parameters before non-default ones?

From: Date: Thu, 09 Dec 2021 05:22:24 +0000
Subject: Allow default parameters before non-default ones?
Groups: php.internals 
Request: Send a blank email to internals+get-116597@lists.php.net to get a copy of this message
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

« previous php.internals (#116597) next »