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

From: Date: Wed, 30 Sep 2020 15:37:04 +0000
Subject: Doc #80032 [Fbk->Asn]: 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-17931@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 User updated by: antonfedonyuk at gmail dot com Reported by: antonfedonyuk at gmail dot com Summary: Can't use valid callback as default value for callable parameters -Status: Feedback +Status: Assigned Type: Documentation Problem Package: *General Issues Operating System: Any PHP Version: 7.4.9 Assigned To: cmb Block user comment: N Private report: N New Comment: cmb@php.net iterable not scalar too Previous Comments: ------------------------------------------------------------------------ [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 (#17931) next »