PHP 7 Closure::call()

Closure::call() method is added in PHP 7.It is shorthand way to temporarily bind an object scope to a closure and invoke it. Performance of Closure::call() method is much faster as compared to bindTo of PHP 5.6.

<?php
class Bunny {private $x = 5;}

// Pre PHP 7 code
$getValue = function() {return $this->x;};
$getXCB = $getValue->bindTo(new Bunny, 'Bunny'); // intermediate closure
echo $getXCB()."
"; // PHP 7+ code $getValue = function() {return $this->x;}; echo $getValue->call(new Bunny);

OutPut

The above example will output: 5
5