|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-08-21 13:15 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2019-08-21 13:15 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 08:00:01 2025 UTC |
Description: ------------ When i want to write facade for function that works by reference i should fully copy function signature into facade, otherwise when unpacking facade loses all references or something. It means i cant decorate or make facade with arguments unpacking, because i'll lost all references on these bridge. Test script: --------------- // declare function append(array &$ref) { $ref[] = 1; } Class Lib { public static function __callStatic($method, $arguments) { // just ignore $method for example... return append(...$arguments); // could be call_user_func('append', ...$arguments); // could be call_user_func_array('append', $arguments); // even could be call_user_func([ SomeOtherClass::class, 'append' ], ...$arguments); } } // run $arr = [1]; append($arr); var_dump($arr); // [1,1] // OK! Lib::neverMind($arr); var_dump($arr); // [1,1] // WTF? It should unpack args by references and then copy-on-write! Seems copy-on-write triggered on unpacking Expected result: ---------------- Saving references when passing arguments to child function Take care about magic __call, __callStatic and so on where we have 2nd parameter with arguments (possible packing)