[php-src] PR #25771: Fix partial application treating methods named assert() as the global assert()
| From: | hohphu8 | Date: | Thu, 26 Nov 2026 04:35:51 +0000 |
| Subject: | [php-src] PR #25771: Fix partial application treating methods named assert() as the global assert() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41031@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25771
Author: hohphu8
In
zp_compile_forwarding_call() (Zend/zend_partial.c),
is_assert is decided by comparing only the function name with
"assert". A partial application of a method named assert, such
as $obj->assert(?) or Cls::assert(?), therefore matches, and the
generated code calls \call_user_func('assert', ...), which invokes the global
assert() instead of the method. With zend.assertions=1 this throws an
AssertionError instead of calling the method.
This restricts the check to internal functions without a class scope (function->type ==
ZEND_INTERNAL_FUNCTION && !function->common.scope).
Adds Zend/tests/partial_application/method_named_assert.phpt covering instance and
static methods named assert, plus a control that partial application of the real
\assert(?) still works. It fails before the fix and passes after.
Note: I found this through source inspection with an automated/LLM-assisted tool, then reproduced
and verified it myself.