Req #76904 [Com]: New Closure class method suggestion

From: Date: Wed, 19 Sep 2018 17:20:54 +0000
Subject: Req #76904 [Com]: New Closure class method suggestion
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217139@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 Comment by: Wes dot example at example dot org Reported by: hello at rayfung dot hk Summary: New Closure class method suggestion Status: Open Type: Feature/Change Request Package: *General Issues PHP Version: 7.2.10 Block user comment: N Private report: N New Comment: already exists. $closure->call($newThis, ...$arguments); Previous Comments: ------------------------------------------------------------------------ [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 (#217139) next »