Req #70324 [NEW]: Closure::call() equivalent for variadics

From: Date: Sat, 22 Aug 2015 02:45:21 +0000
Subject: Req #70324 [NEW]: Closure::call() equivalent for variadics
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195420@lists.php.net to get a copy of this message
From: m dot chojnacki at muyo dot io Operating system: PHP version: 7.0.0RC1 Package: Class/Object related Bug Type: Feature/Change Request Bug description:Closure::call() equivalent for variadics Description: ------------ As of PHP7, Closure::call() allows us to skip the intermediary step of binding to a different object before invoking the closure. However, it assumes the list of arguments is known beforehand, just like call_user_func() does. For variadics that list is generally unknown. Having to rely on call_user_func_array() in this case means we're still forced to first manually bind the Closure before invoking it. Sure, it works, but from my perspective this feels like a missing part of a nice addition to PHP and is somewhat unintuitive that you can do one, but can't do the other. In JavaScript, for example, this use case is served by separate call() and apply() function prototype methods, where apply() accepts a scope and an array of arguments while call() works like the equivalent Closure:call() in PHP7. I would very much love to see a similar implementation in PHP and find it is a suitable, complementary addition. -- Edit bug report at https://bugs.php.net/bug.php?id=70324&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70324&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70324&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70324&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70324&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70324&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70324&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70324&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70324&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70324&r=support Expected behavior: https://bugs.php.net/fix.php?id=70324&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70324&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70324&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70324&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70324&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70324&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70324&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70324&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70324&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70324&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70324&r=mysqlcfg

« previous php.bugs (#195420) next »