How do I force to pass an argument by reference?
| From: | Ruslan Osmanov | Date: | Fri, 12 Feb 2016 10:34:39 +0000 |
| Subject: | How do I force to pass an argument by reference? | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-13539@lists.php.net to get a copy of this message | ||
Hi,
I can't understand why the pass_by_ref argument of ZEND_ARG_OBJ_INFO()
doesn't work for me.
I want just the same fatal error, as the standard usort() function
returns, if the argument is not a variable:
usort([1,0]);
Fatal error: Only variables can be passed by reference
The following code should enable the same functionality, but it doesn't:
ZEND_BEGIN_ARG_INFO_EX(arginfo_bufferevent__construct, 0, 0, 1)
ZEND_ARG_OBJ_INFO(1, base, EventBase, 0)
ZEND_ARG_INFO(0, socket)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, readcb)
ZEND_ARG_INFO(0, writecb)
ZEND_ARG_INFO(0, eventcb)
ZEND_END_ARG_INFO();
PHP_ME(EventBufferEvent, __construct,
arginfo_bufferevent__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
There're no complains regarding references here:
$b = new EventBufferEvent(new EventBase());
The reflection information only confirms that the code is right:
$ php --rf eventbufferevent::__construct
Method [ <internal:event, ctor> public method __construct ] {
- Parameters [6] {
Parameter #0 [ <required> EventBase &$base ]
Parameter #1 [ <optional> $socket ]
Parameter #2 [ <optional> $options ]
Parameter #3 [ <optional> $readcb ]
Parameter #4 [ <optional> $writecb ]
Parameter #5 [ <optional> $eventcb ]
}
}
Please help me to understand what's wrong with my code, or how do I
force passing by reference?
--
Ruslan Osmanov