krakjoe / uopz

User Operations for Zend
Other
356 stars 47 forks source link

Can not get hook setted by uopz_set_hook for some functions names #99

Closed noldor closed 5 years ago

noldor commented 5 years ago

uopz_get_hook return null on some functions names.

Working example:

<?php

declare(strict_types=1);

function stub() {
    return 123;
}

uopz_set_hook('stub', function () {
    var_dump('hook called');
});

$a = uopz_get_hook('stub');

var_dump(stub());

var_dump($a);

It outputs:

/test.php:10:
string(11) "hook called"
/test.php:15:
int(123)
/test.php:17:
class Closure#1 (0) {
}

But if rename function on line 5 like stubFunc, testFunc, Stub uopz_get_hook would return null

<?php

declare(strict_types=1);

function Stub() {
    return 123;
}

uopz_set_hook('Stub', function () {
    var_dump('hook called');
});

$a = uopz_get_hook('Stub');

var_dump(Stub());

var_dump($a);

outputs:

/test.php:10:
string(11) "hook called"
/test.php:15:
int(123)
/test.php:17:
NULL

uopz: 5.1.0 php: 7.1.25, 7.2.13, 7.3.0 os: Ubuntu