Skip to content
This repository was archived by the owner on Apr 14, 2018. It is now read-only.

Commit 612c5e6

Browse files
committed
fix copy & create for class based functions on uopz before 5
1 parent a8ac891 commit 612c5e6

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/Monitors/MonitorBase.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,34 @@ public function listen($func, Closure $callback)
6666
private function set_hook($func, Closure $callback)
6767
{
6868

69+
//class
6970
if(is_array($func)){
7071
uopz_set_hook($func[0],$func[1],$callback);
7172
return;
7273
}
74+
75+
//single function
7376
uopz_set_hook($func,$callback);
7477
}
7578

76-
//TODO: test versions before UOPZ 5
77-
private function set_function($function, Closure $callback)
79+
private function set_function($func, Closure $callback)
7880
{
7981

80-
//uopz_copy
81-
$originalFunc = uopz_copy($function);
82-
uopz_function($function, function() use($originalFunc, $callback) {
82+
//class
83+
if(is_array($func)){
84+
$originalFunc = uopz_copy($func[0],$func[1]);
85+
uopz_function($func[0],$func[1], function() use($originalFunc, $callback) {
86+
$args = func_get_args();
87+
call_user_func_array($callback,$args);
88+
/* can call original func from here */
89+
return call_user_func_array($originalFunc,$args);
90+
});
91+
return;
92+
}
93+
94+
//single function
95+
$originalFunc = uopz_copy($func);
96+
uopz_function($func, function() use($originalFunc, $callback) {
8397
$args = func_get_args();
8498
call_user_func_array($callback,$args);
8599
/* can call original func from here */

0 commit comments

Comments
 (0)