mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
zend_call_function: emit function deprecation before setting up call frame (#20264)
This commit is contained in:
committed by
GitHub
parent
b3d846521b
commit
005d04aa96
@@ -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
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user