Skip to content
Closed
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
38 changes: 38 additions & 0 deletions Zend/tests/function_arguments/gh20435_2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--TEST--
GH-20435: ZEND_CALL_HAS_EXTRA_NAMED_PARAMS & magic methods in debug_backtrace_get_args()
--FILE--
<?php

class C {
public static function __callStatic($name, $args) {
echo (new Exception())->__toString(), "\n\n";
}
public function __call($name, $args) {
echo (new Exception())->__toString(), "\n\n";
}
public function __invoke(...$args) {
echo (new Exception())->__toString(), "\n";
}
}

$c = new C();
$c->foo(bar: 'bar');
C::foo(bar: 'bar');
$c(bar: 'bar');

?>
--EXPECTF--
Exception in %s:%d
Stack trace:
#0 %s(%d): C->__call('foo', Array)
#1 {main}

Exception in %s:%d
Stack trace:
#0 %s(%d): C::__callStatic('foo', Array)
#1 {main}

Exception in %s:%d
Stack trace:
#0 %s(%d): C->__invoke(bar: 'bar')
#1 {main}
8 changes: 5 additions & 3 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1680,12 +1680,14 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) /
ZVAL_EMPTY_ARRAY(arg_array);
}

if (ZEND_CALL_INFO(call) & ZEND_CALL_HAS_EXTRA_NAMED_PARAMS) {
if ((ZEND_CALL_INFO(call) & ZEND_CALL_HAS_EXTRA_NAMED_PARAMS)
/* __call and __callStatic are non-variadic, potentially with
* HAS_EXTRA_NAMED_PARAMS set. Don't add extra args, as they're already
* contained in the 2nd param. */
&& (call->func->common.fn_flags & ZEND_ACC_VARIADIC)) {
zend_string *name;
zval *arg;

ZEND_ASSERT(call->func->common.fn_flags & ZEND_ACC_VARIADIC);

zend_attribute *attribute = zend_get_parameter_attribute_str(
call->func->common.attributes,
"sensitiveparameter",
Expand Down
Loading