Req #76904 [Fbk->NoF]: New Closure class method suggestion

From: Date: Sun, 07 Oct 2018 09:38:06 +0000
Subject: Req #76904 [Fbk->NoF]: New Closure class method suggestion
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217458@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76904&edit=1 ID: 76904 Updated by: cmb@php.net Reported by: hello at rayfung dot hk Summary: New Closure class method suggestion -Status: Feedback +Status: No Feedback Type: Feature/Change Request Package: *General Issues PHP Version: 7.2.10 Assigned To: cmb Block user comment: N Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. Previous Comments: ------------------------------------------------------------------------ [2018-09-20 12:52:34] cmb@php.net Indeed, what's wrong with ::call() and using argument unpacking (aka. spread operator)? ------------------------------------------------------------------------ [2018-09-19 17:22:13] Wes dot example at example dot org so, for instance $closure->call($three, ...['Peter', 30]); ------------------------------------------------------------------------ [2018-09-19 17:20:54] Wes dot example at example dot org already exists. $closure->call($newThis, ...$arguments); ------------------------------------------------------------------------ [2018-09-19 17:16:45] hello at rayfung dot hk Description: ------------ Closure::apply — Binds and calls the closure with an array of parameters #Description ``` public mixed Closure::apply ( object $newthis [, array $param_arr ] ) ``` Temporarily binds the closure to newthis, and calls it with any given array of parameters. #Parameters newthis The object to bind the closure to for the duration of the call. param_arr The parameters to be passed to the callback, as an indexed array. #Return Values Returns the return value of the closure. Test script: --------------- $closure = function($name, $age) { return $name . ' is ' . $age . ' years old'; } $closure->apply($three, ['Peter', 30]); Expected result: ---------------- Peter is 30 years old ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76904&edit=1

« previous php.bugs (#217458) next »