[php-src] PR #15437: Added `default` as an expression in argument lists

From: Date: Fri, 16 Aug 2024 00:09:56 +0000
Subject: [php-src] PR #15437: Added `default` as an expression in argument lists
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-27986@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/15437 Author: Bilge This is my initial draft for adding default as an expression. In this version, default still cannot be used as an expression, it may merely be used by itself as a placeholder for the default value of the callee function or method. ### Example ```php <?php function f($x = 'You win', $y = new C) { var_dump($x); var_dump($y); } class C { function F($x = 'Mega winning', $y = 123) { var_dump($x); var_dump($y); } } f(default, default); $c = new C()->F(default, default); ``` ``` string(7) "You win" object(C)#3 (0) { } string(12) "Mega winning" int(123) ``` ### TODO * Handle the case where default does not match a parameter in the callee (too many arguments). * Handle the case where default matches a parameter in the callee that does not have a default value. * General expression support. * Nested function calls. * Closures. * Callable objects. * Anonymous classes. * Optimizations.

« previous php.git-pulls (#27986) next »