Commit 5e8d15e5701 for php

commit 5e8d15e57017efb1076b513f5bce67c9ce980f25
Author: ndossche <7771979+ndossche@users.noreply.github.com>
Date:   Sun Nov 8 16:26:50 2026 +0100

    PFA: Fix support for never-returning functions

    The AST rewrite tried to add a return statement, so I extended the check
    from void to void or never.

    Closes GH-25322.

diff --git a/NEWS b/NEWS
index 7018b13c075..2a5c9d1d4a4 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ PHP                                                                        NEWS
     hooked subclass). (Lazizbek Ergashev)
   . Fixed bug GH-25314 (Assertion in ZEND_DO_FCALL: reference returned by
     &__get() reaches property hook TMP result). (ndossche)
+  . Fix support for never-returning functions in PFAs. (ndossche)

 - Curl:
   . Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)
diff --git a/Zend/tests/partial_application/never_return.phpt b/Zend/tests/partial_application/never_return.phpt
new file mode 100644
index 00000000000..95dc1743a3a
--- /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/zend_partial.c b/Zend/zend_partial.c
index d367b5ee21a..1108cff2301 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);