Bug #78433 [Opn->Dup]: I found nowhere possibility to unpack reference expected variables to child fn

From: Date: Wed, 21 Aug 2019 13:15:36 +0000
Subject: Bug #78433 [Opn->Dup]: I found nowhere possibility to unpack reference expected variables to child fn
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222339@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78433&edit=1 ID: 78433 Updated by: nikic@php.net Reported by: 6562680 at gmail dot com Summary: I found nowhere possibility to unpack reference expected variables to child fn -Status: Open +Status: Duplicate Type: Bug Package: Reflection related Operating System: Win10 PHP Version: 7.2.21 Block user comment: N Private report: N New Comment: Duplicate of bug #71256. Previous Comments: ------------------------------------------------------------------------ [2019-08-21 09:47:38] 6562680 at gmail dot com 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) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78433&edit=1

« previous php.bugs (#222339) next »