Should the engine be able to pass variables by reference of userland functions

php.internals

Girgias

3 years ago
Hello internals, While working on cleaning up the FCI/FCC API I stumbled upon the zend_fcall_info_args_ex() function. This function allows the engine to pass "variables" to userland functions that expect a by-ref parameter. This is currently only used within php-src in PDO when calling the constructor of classes where the result of a statement should be stored in PDO::FETCH_CLASS mode. I am wondering if this makes any sense to continue support in general, and thus in this specific case. As every other engine call to userland function passes by value. A PR of this change is located: https://github.com/php/php-src/pull/9725/files What are your opinions? Best regards, George P. Banyard

Kamil Tekiela

3 years ago
Hi, I am not sure if we should still support it. But I don't think it's unthinkable to expect such feature from PHP. However, personally, I don't find pass-by-ref that useful in general. The question is whether this feature is used a lot in the wild. If we decide to drop support for this, it should probably go through a deprecation phase. Regards, Kamil

Jordan LeDoux

3 years ago
On Wed, Oct 19, 2022 at 7:37 AM Kamil Tekiela <tekiela246@gmail.com> wrote:
> Hi, > > I am not sure if we should still support it. But I don't think it's > unthinkable to expect such feature from PHP. However, personally, I don't > find pass-by-ref that useful in general. The question is whether this > feature is used a lot in the wild. > > If we decide to drop support for this, it should probably go through a > deprecation phase. > > Regards, > Kamil >
Pass by-ref is used a LOT in the wild, but I didn't interpret George's question as "should we remove pass by-ref from userland entirely". Surely the engine also supports pass by-ref somewhere in the VM as well as the place that was mentioned, it just does it in a different way? Jordan