1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  Correctly handle extra named args for magic call in debug_backtrace_get_args()
This commit is contained in:
Ilija Tovilo
2025-11-12 00:33:37 +01:00
2 changed files with 43 additions and 3 deletions

View File

@@ -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}

View File

@@ -1853,12 +1853,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",