1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 00:48:25 +02:00
Files
archived-php-src/ext/zend_test/tests/observer_zend_call_function_01.phpt
T
Bob Weinand 625f164963 Include internal functions in the observer API
There are two main motivations to this:
a) The logic for handling internal and userland observation can be unified.
b) Unwinding of observed functions on a bailout does notably not include observers. Even if users of observers were to ensure such handling themselves, it would be impossible to retain the relative ordering - either the user has to unwind all internal observed frames before the automatic unwinding (zend_observer_fcall_end_all) or afterwards, but not properly interleaved.

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-07-30 19:20:55 +02:00

43 lines
717 B
PHP

--TEST--
Observer: Calls that go through zend_call_function are observed
--EXTENSIONS--
zend_test
--INI--
zend_test.observer.enabled=1
zend_test.observer.observe_all=1
--FILE--
<?php
function sum($carry, $item) {
$carry += $item;
return $carry;
}
$a = [1, 2, 3, 4, 5];
// array_reduce() calls zend_call_function() under the hood
var_dump(array_reduce($a, 'sum'));
echo 'Done' . PHP_EOL;
?>
--EXPECTF--
<!-- init '%s' -->
<file '%s'>
<!-- init array_reduce() -->
<array_reduce>
<!-- init sum() -->
<sum>
</sum>
<sum>
</sum>
<sum>
</sum>
<sum>
</sum>
<sum>
</sum>
</array_reduce>
<!-- init var_dump() -->
<var_dump>
int(15)
</var_dump>
Done
</file '%s'>