Doc #80032 [Fbk->NoF]: Can't use valid callback as default value for callable parameters

From: Date: Sun, 11 Oct 2020 04:22:15 +0000
Subject: Doc #80032 [Fbk->NoF]: Can't use valid callback as default value for callable parameters
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17986@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80032&edit=1 ID: 80032 Updated by: php-bugs@lists.php.net Reported by: antonfedonyuk at gmail dot com Summary: Can't use valid callback as default value for callable parameters -Status: Feedback +Status: No Feedback Type: Documentation Problem Package: *General Issues Operating System: Any PHP Version: 7.4.9 Assigned To: cmb Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2020-09-30 15:47:55] cmb@php.net > iterable not scalar too Well, the documentation mentions after the scalar examples: | PHP also allows the use of arrays and the special type NULL as | default values, […] ------------------------------------------------------------------------ [2020-09-30 15:37:04] antonfedonyuk at gmail dot com cmb@php.net iterable not scalar too ------------------------------------------------------------------------ [2020-09-30 12:19:28] cmb@php.net The manual states[1]: | A function may define C++-style default values for scalar | arguments as follows: Since callables are not scalar, is there anything to add? [1] <https://www.php.net/manual/en/functions.arguments.php#functions.arguments.default> ------------------------------------------------------------------------ [2020-08-28 19:16:11] antonfedonyuk at gmail dot com Description: ------------ Can't use valid callback(string or array) as default value of callable parameters. It's generate fatal error: Default value for parameters with callable type can only be NULL. The guide doesn't contain any notes on this issue. Test script: --------------- <?php function test(callable $callback = 'strtoupper') { return $callback(); } ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80032&edit=1

« previous php.doc.bugs (#17986) next »