|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78433 I found nowhere possibility to unpack reference expected variables to child fn
Submitted: 2019-08-21 09:47 UTC Modified: 2019-08-21 13:15 UTC
From: 6562680 at gmail dot com Assigned:
Status: Duplicate Package: Reflection related
PHP Version: 7.2.21 OS: Win10
Private report: No CVE-ID: None
 [2019-08-21 09:47 UTC] 6562680 at gmail dot com
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];
var_dump($arr); // [1,1] // OK!
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)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-21 13:15 UTC]
-Status: Open +Status: Duplicate
 [2019-08-21 13:15 UTC]
Duplicate of bug #71256.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 09:03:36 2021 UTC