|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-06-05 23:07 UTC] cmb@php.net
[2018-07-27 14:57 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2018-07-27 14:57 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 16:00:01 2025 UTC |
Description: ------------ Calling call_user_func(_array) more than one level deep will no longer take into account the callback object's state. E.g. call_user_func("call_user_func", $callback); I am not entirely certain this is a bug: after all, usually once a function is called, an object's environment is left. However, call_user_func seems to be the exception to this rule, because the function would lose its significance otherwise. Test script: --------------- Anyway, class A { private function z() { echo __METHOD__; } public function x() { $callback = [[new $this(), "z"], []]; $callback[0](...$callback[1]); } } (new A())->x(); // This works fine and can be rewritten to: class A { private function z() { echo __METHOD__; } public function x() { $callback = [[new $this(), "z"], []]; call_user_func_array("call_user_func_array", $callback); } } (new A())->x(); Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method A::z() in FILE. Expected result: ---------------- Stacked invocation of call_user_func(_array) should not leave the callback object's state. Actual result: -------------- Stacked invocation of call_user_func(_array) leaves the callback object's state.