note 117434 rejected from closure.call by ajf

From: Date: Tue, 06 Oct 2015 09:07:10 +0000
Subject: note 117434 rejected from closure.call by ajf
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203915@lists.php.net to get a copy of this message
Note Submitter: Hyse ---- Closure::call() does not exist, at least in PHP 5.5.23 (cli) (built: Mar 21 2015 22:04:59) Instead, to achieve the desired effect: Use the Closure::bindTo() method and invoke the __invoke() magic method from the returned closure. <?php $obj = new stdClass(); $obj->foo = 'baz'; $a = function($arg1, $arg2) { return join(chr(44), [$arg1, $arg2, $this->foo]); }; $b = $a->bindTo($obj); echo $b('foo', 'bar'); ?>

« previous php.notes (#203915) next »