Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Zend/tests/attributes/nodiscard/007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ zend_test_nodiscard();
?>
--EXPECTF--
<!-- internal enter NoDiscard::__construct() -->
<!-- internal leave NoDiscard::__construct() -->

Warning: The return value of function zend_test_nodiscard() should either be used or intentionally ignored by casting it as (void), custom message in %s on line %d
<!-- internal enter zend_test_nodiscard() -->
<!-- internal leave zend_test_nodiscard() -->
23 changes: 21 additions & 2 deletions ext/zend_test/observer.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,40 @@ static void (*zend_test_prev_execute_internal)(zend_execute_data *execute_data,
static void zend_test_execute_internal(zend_execute_data *execute_data, zval *return_value) {
zend_function *fbc = execute_data->func;

ZEND_ASSERT(!ZEND_USER_CODE(fbc->type));

if (fbc->common.function_name) {
if (fbc->common.scope) {
php_printf("%*s<!-- internal enter %s::%s() -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
} else {
php_printf("%*s<!-- internal enter %s() -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->common.function_name));
}
} else if (ZEND_USER_CODE(fbc->type)) {
php_printf("%*s<!-- internal enter '%s' -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->op_array.filename));
}

ZT_G(observer_nesting_depth)++;

if (zend_test_prev_execute_internal) {
zend_test_prev_execute_internal(execute_data, return_value);
} else {
fbc->internal_function.handler(execute_data, return_value);
}

ZT_G(observer_nesting_depth)--;

if (fbc->common.function_name) {
if (EG(exception)) {
php_printf("%*s<!-- Exception: %s -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(EG(exception)->ce->name));
Comment thread
iluuu1994 marked this conversation as resolved.
}

smart_str retval_info = {0};
get_retval_info(return_value, &retval_info);
if (fbc->common.scope) {
php_printf("%*s<!-- internal leave %s::%s()%s -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name), retval_info.s ? ZSTR_VAL(retval_info.s) : "");
} else {
php_printf("%*s<!-- internal leave %s()%s -->\n", 2 * ZT_G(observer_nesting_depth), "", ZSTR_VAL(fbc->common.function_name), retval_info.s ? ZSTR_VAL(retval_info.s) : "");
}
smart_str_free(&retval_info);
}
}

static ZEND_INI_MH(zend_test_observer_OnUpdateCommaList)
Expand Down
18 changes: 17 additions & 1 deletion ext/zend_test/tests/execute_internal.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Test zend_execute_internal being called
zend_test
--INI--
zend_test.observer.execute_internal=1
zend_test.observer.show_return_value=1
--FILE--
<?php

Expand All @@ -13,9 +14,24 @@ function f($a) {

f(time() > 0 ? [1, 2, 3] : []);

array_map("count", [[], [1, 2]]);

?>
--EXPECT--
--EXPECTF--
<!-- internal enter time() -->
<!-- internal leave time():%d -->
Comment thread
iluuu1994 marked this conversation as resolved.
<!-- internal enter array_sum() -->
<!-- internal leave array_sum():6 -->
<!-- internal enter var_dump() -->
int(6)
<!-- internal leave var_dump():NULL -->
<!-- internal enter array_map() -->
<!-- internal enter count() -->
<!-- internal leave count():0 -->
<!-- internal enter count() -->
<!-- internal leave count():2 -->
<!-- internal leave array_map():
array (
0 => 0,
1 => 2,
) -->
Loading