Skip to content

Instantly share code, notes, and snippets.

@ThijsFeryn
Created November 30, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThijsFeryn/1509aa359d9fc4c9ddaa to your computer and use it in GitHub Desktop.
Save ThijsFeryn/1509aa359d9fc4c9ddaa to your computer and use it in GitHub Desktop.
PHP 7 Closure::call()
<?php
/**
* Closure::call()
*/
class Foo
{
private $foo = 'bar';
}
$getFooCallback = function() {
return $this->foo;
};
//PHP5 style
$binding = $getFooCallback->bindTo(new Foo,'Foo');
echo $binding().PHP_EOL;
//PHP7 style
echo $getFooCallback->call(new Foo).PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment