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
25 changes: 25 additions & 0 deletions Zend/tests/functions/zend_call_function_deprecated_frame.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Deprecated function notice promoted to exception within zend_call_function()
--FILE--
<?php

#[Deprecated]
function foo(string $v) {
return $v . '!';
}

set_error_handler(function ($number, $message) {
throw new Exception($message);
});

$a = array_map(foo(...), ['Hello', 'World']);
var_dump($a);

?>
--EXPECTF--
Fatal error: Uncaught Exception: Function foo() is deprecated in %s:%d
Stack trace:
#0 [internal function]: {closure:%s:%d}(16384, 'Function foo() ...', '%s', %d)
#1 %s(%d): array_map(Object(Closure), Array)
#2 {main}
thrown in %s on line %d
7 changes: 3 additions & 4 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,18 +862,17 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
call_info = ZEND_CALL_TOP_FUNCTION | ZEND_CALL_DYNAMIC | ZEND_CALL_HAS_THIS;
}

call = zend_vm_stack_push_call_frame(call_info,
func, fci->param_count, object_or_called_scope);

if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_DEPRECATED)) {
zend_deprecated_function(func);

if (UNEXPECTED(EG(exception))) {
zend_vm_stack_free_call_frame(call);
return SUCCESS;
}
}

call = zend_vm_stack_push_call_frame(call_info,
func, fci->param_count, object_or_called_scope);

for (uint32_t i = 0; i < fci->param_count; i++) {
zval *param = ZEND_CALL_ARG(call, i+1);
zval *arg = &fci->params[i];
Expand Down