Bug #78433 [NEW]: I found nowhere possibility to unpack reference expected variables to child fn
| From: | 6562680 at gmail dot com | Date: | Wed, 21 Aug 2019 09:47:38 +0000 |
| Subject: | Bug #78433 [NEW]: I found nowhere possibility to unpack reference expected variables to child fn | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222335@lists.php.net to get a copy of this message | ||
From: 6562680 at gmail dot com
Operating system: Win10
PHP version: 7.2.21
Package: Reflection related
Bug Type: Bug
Bug description:I found nowhere possibility to unpack reference expected variables to child fn
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 bug report at https://bugs.php.net/bug.php?id=78433&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78433&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78433&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78433&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78433&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78433&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78433&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78433&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78433&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78433&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78433&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78433&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78433&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78433&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78433&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78433&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78433&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78433&r=mysqlcfg