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

From: Date: Sun, 08 Nov 2026 21:55:57 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143462@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-11-08T22:55:33+01:00 Commit: https://github.com/php/php-src/commit/a53dd72f7a3551bd92c43e0faecb30435f316d3a Raw diff: https://github.com/php/php-src/commit/a53dd72f7a3551bd92c43e0faecb30435f316d3a.diff Merge branch 'PHP-8.6' * PHP-8.6: PFA: Fix support for never-returning functions Fix GH-25314: Assertion in ZEND_DO_FCALL: reference returned by &__get() reaches property hook TMP result Changed paths: A Zend/tests/partial_application/never_return.phpt A Zend/tests/property_hooks/gh25314.phpt M Zend/zend_object_handlers.c M Zend/zend_partial.c Diff: diff --git a/Zend/tests/partial_application/never_return.phpt b/Zend/tests/partial_application/never_return.phpt new file mode 100644 index 000000000000..95dc1743a3a0 --- /dev/null +++ b/Zend/tests/partial_application/never_return.phpt @@ -0,0 +1,14 @@ +--TEST-- +PFA can be made from never function +--FILE-- +<?php + +function neverReturns($msg): never { + throw new Error($msg); +} + +var_dump(neverReturns(?) instanceof Closure); + +?> +--EXPECT-- +bool(true) diff --git a/Zend/tests/property_hooks/gh25314.phpt b/Zend/tests/property_hooks/gh25314.phpt new file mode 100644 index 000000000000..a72bef2d9fb9 --- /dev/null +++ b/Zend/tests/property_hooks/gh25314.phpt @@ -0,0 +1,31 @@ +--TEST-- +GH-25314 (Assertion in ZEND_DO_FCALL: reference returned by &__get() reaches property hook TMP result) +--CREDITS-- +YuanchengJiang +--FILE-- +<?php + +class P { + public int $d = 1; + function &__get($name) {} +} +class C extends P { + public int $d = 2 { get => parent::$d::get(); } +} +class GC extends C { + public int $d { get => parent::$d::get(); } +} + +var_dump((new GC)->d); + +?> +--EXPECTF-- +Notice: Only variable references should be returned by reference in %s on line %d + +Fatal error: Uncaught TypeError: Value of type null returned from GC::__get() must be compatible with unset property GC::$d of type int in %s:%d +Stack trace: +#0 %s(%d): P->$d::get() +#1 %s(%d): C->$d::get() +#2 %s(%d): GC->$d::get() +#3 {main} + thrown in %s on line %d diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 823e8ae4d207..865bc08895b2 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1878,11 +1878,15 @@ static ZEND_FUNCTION(zend_parent_hook_get_trampoline) } zval rv; - const zval *retval = obj->handlers->read_property(obj, prop_name, BP_VAR_R, NULL, &rv); + zval *retval = obj->handlers->read_property(obj, prop_name, BP_VAR_R, NULL, &rv); if (retval == &rv) { RETVAL_COPY_VALUE(retval); + if (UNEXPECTED(Z_ISREF_P(return_value))) { + /* __get() may return by reference. */ + zend_unwrap_reference(return_value); + } } else { - RETVAL_COPY(retval); + RETVAL_COPY_DEREF(retval); } clean: diff --git a/Zend/zend_partial.c b/Zend/zend_partial.c index 4a22c58976da..90830d1d1623 100644 --- a/Zend/zend_partial.c +++ b/Zend/zend_partial.c @@ -663,8 +663,8 @@ static zend_ast *zp_compile_forwarding_call( call_ast = zend_ast_create(ZEND_AST_CALL, func_name_ast, args_ast); } - /* Void functions can not 'return $expr' */ - if (ZEND_TYPE_FULL_MASK(return_type) & MAY_BE_VOID) { + /* Void and never functions can not 'return $expr' */ + if (ZEND_TYPE_FULL_MASK(return_type) & (MAY_BE_VOID|MAY_BE_NEVER)) { stmts_ast = zend_ast_list_add(stmts_ast, call_ast); } else { zend_ast *return_ast = zend_ast_create(ZEND_AST_RETURN, call_ast);

« previous php.cvs (#143462) next »