Skip to content

Instantly share code, notes, and snippets.

@Chemaclass
Last active September 21, 2019 22:55
Show Gist options
  • Select an option

  • Save Chemaclass/382488091b3bde21b8a79f87ec26877a to your computer and use it in GitHub Desktop.

Select an option

Save Chemaclass/382488091b3bde21b8a79f87ec26877a to your computer and use it in GitHub Desktop.
Docu - Closure::call
<?php
class A {
private $x = "1";
}
// Pre PHP 7 code
$getX = function() {return $this->x;};
$getXCB = $getX->bindTo(new A, 'A'); // intermediate closure
echo $getXCB(); // outputs "1"
// PHP 7+ code
$getX = function() {return $this->x;};
echo $getX->call(new A); // outputs "1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment