Bug #60572 [Bgs]: Can't make a optional callback arguments in extension
| From: | laruence@php.net | Date: | Tue, 20 Dec 2011 13:51:03 +0000 |
| Subject: | Bug #60572 [Bgs]: Can't make a optional callback arguments in extension | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165992@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60572&edit=1
ID: 60572
Updated by: laruence@php.net
Reported by: laruence@php.net
Summary: Can't make a optional callback arguments in
extension
Status: Bogus
Type: Bug
Package: *General Issues
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
ah, thanks cataphract.
Previous Comments:
------------------------------------------------------------------------
[2011-12-20 13:17:38] cataphract@php.net
Optional means "accepting the argument was not given", not "accepting a NULL".
To accept NULLs, you have to use !, otherwise the argument is coerced to whatever type you're
expecting, which is not possible here.
so
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|f!", &key, &klen,
&fci, &fci_cache) {
------------------------------------------------------------------------
[2011-12-20 09:52:59] laruence@php.net
Description:
------------
following codes in extension didn't work as expected:
....
zend_fcall_info fci = {0};
zend_fcall_info_cache fci_cache;
...
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|f", &key, &klen,
&fci, &fci_cache) {
return;
}
if (!fci.size) {
// not a valid callback
}
in PHP script:
php_ext_function("name", NULL);
result in:
argument 2 not a valid callback...
I haved tried set the arginfo with all_null.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60572&edit=1