Commit 415e68cc0af for php

commit 415e68cc0afe3c500049bf281fe54381dcc402dc
Author: Ho Hoang Phu <79566948+hohphu8@users.noreply.github.com>
Date:   Thu Nov 26 23:31:26 2026 +0700

    Fix partial application treating methods named assert() as the global assert() (#25771)

    zp_compile_forwarding_call() checked function_name against ZEND_STR_ASSERT without checking ZEND_INTERNAL_FUNCTION and common.scope == NULL, causing partial application on methods or user functions named assert() to call global assert().

diff --git a/NEWS b/NEWS
index 8222edce215..aefa07c3c73 100644
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,8 @@ PHP                                                                        NEWS
   . Fixed bug GH-25379 (array_map() foreach optimization changes callback
     semantics). (prateekbhujel)
   . Fix OSS-Fuzz #588264417. (ndossche)
+  . Fixed partial application treating methods named assert() as the global
+    assert(). (hohphu8)

 - Curl:
   . Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)
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 00000000000..f1682416e5c
--- /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 b227c1f9e25..5c980d76e4a 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;