Beispiel #1
0
echo "\$d = \$staticNS->bindto(NULL, 'Y');\n";
$staticNS = static function () {
    echo "self::\$x   = ";
    var_dump(self::$x);
    echo "static::\$x = ";
    var_dump(static::$x);
};
$d = $staticNS->bindto(NULL, 'Y');
$res = (new ReflectionFunction($d))->getClosureScopeClass();
if ($res) {
    var_dump($res->getName());
}
$d();
echo "=====================================================\n";
echo "\$d = \$staticS->bindto(NULL, 'Y');\n";
$staticS = X::getS();
$d = $staticS->bindto(NULL, 'Y');
$res = (new ReflectionFunction($d))->getClosureScopeClass();
if ($res) {
    var_dump($res->getName());
}
$d();
echo "=====================================================\n";
echo "\$R = \$Q->bindto(new Y, 'static');\n";
$Q = (new X())->get();
$R = $Q->bindto(new Y(), 'static');
$res = (new ReflectionFunction($R))->getClosureScopeClass();
if ($res) {
    var_dump($res->getName());
}
$R();