[php-src] master: Merge branch 'PHP-8.6'

From: Date: Thu, 26 Nov 2026 16:31:53 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-144230@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Date: 2026-11-26T17:31:40+01:00 Commit: https://github.com/php/php-src/commit/d72128a754bbc992e2e838436b92b005693a5a2d Raw diff: https://github.com/php/php-src/commit/d72128a754bbc992e2e838436b92b005693a5a2d.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix partial application treating methods named assert() as the global assert() (#25771) Changed paths: A Zend/tests/partial_application/method_named_assert.phpt M Zend/zend_partial.c Diff: diff --git a/Zend/tests/partial_application/method_named_assert.phpt b/Zend/tests/partial_application/method_named_assert.phpt new file mode 100644 index 000000000000..f1682416e5c5 --- /dev/null +++ b/Zend/tests/partial_application/method_named_assert.phpt @@ -0,0 +1,55 @@ +--TEST-- +Partial function application on methods named assert() must invoke the method, while real global assert(?) keeps working +--INI-- +zend.assertions=1 +assert.exception=1 +--FILE-- +<?php + +class Validator { + public function assert(bool $cond, string $label = 'default'): string { + return "INSTANCE:$label:" . ($cond ? 'true' : 'false'); + } + + public static function assertStatic(bool $cond): string { + return "CTRL:" . ($cond ? 'true' : 'false'); + } +} + +class StaticValidator { + public static function assert(bool $cond, string $label = 'static'): string { + return "STATIC:$label:" . ($cond ? 'true' : 'false'); + } +} + +$v = new Validator(); +$ctrl = $v->assertStatic(?); +var_dump($ctrl(false)); + +$p1 = $v->assert(?, 'inst'); +var_dump($p1(false)); + +$p2 = StaticValidator::assert(?, 'cls'); +var_dump($p2(false)); + +$p3 = $v->assert(...); +var_dump($p3(false, 'fcc')); + +// Positive control: real global \assert(?) must still invoke global assert() +$realAssert = \assert(?, 'real-assert-msg'); +var_dump($realAssert(true)); +try { + $realAssert(false); + echo "UNEXPECTED_PASS\n"; +} catch (AssertionError $e) { + echo "REAL_ASSERT_ERR:" . $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +string(10) "CTRL:false" +string(19) "INSTANCE:inst:false" +string(16) "STATIC:cls:false" +string(18) "INSTANCE:fcc:false" +bool(true) +REAL_ASSERT_ERR:real-assert-msg diff --git a/Zend/zend_partial.c b/Zend/zend_partial.c index 346b94400567..093880886d61 100644 --- a/Zend/zend_partial.c +++ b/Zend/zend_partial.c @@ -522,8 +522,10 @@ static zend_ast *zp_compile_forwarding_call( bool forward_superfluous_args, zend_ast *stmts_ast, uint32_t const_args) { - bool is_assert = zend_string_equals(function->common.function_name, - ZSTR_KNOWN(ZEND_STR_ASSERT)); + bool is_assert = function->type == ZEND_INTERNAL_FUNCTION + && !function->common.scope + && zend_string_equals(function->common.function_name, + ZSTR_KNOWN(ZEND_STR_ASSERT)); zend_ast *args_ast = zend_ast_create_list(0, ZEND_AST_ARG_LIST); zend_ast *call_ast = NULL;

« previous php.cvs (#144230) next »