krakjoe / uopz

User Operations for Zend
Other
358 stars 47 forks source link

call_user_func passes incorrect parameter to the function #85

Closed vikramparth closed 5 years ago

vikramparth commented 6 years ago

After calling uopz_set_return, calling a function using call_user_func works incorrectly. Specifically, the parameter that gets passed to the function is incorrect. Instead of the actual parameter getting passed , the name of the function gets passed as the parameter. For e.g. -

<?php

function myfunc($param)
{
    print $param . " world!\n";
}

$closure = function($param) {
    print $param . " universe!\n";
};

// replace myfunc
uopz_set_return("myfunc", $closure, true);

myfunc("hello");
call_user_func("myfunc", "hello");

Output -

hello universe!
myfunc universe!

call_user_func_array doesn't have this problem (however, it calls the original function and not the replaced function. Is that expected?)

PHP version - 7.2.7 uopz version - 5.0.2

krakjoe commented 5 years ago

Sorry about the delay ...

vikramparth commented 5 years ago

Thank you for fixing this!