ReflectionFunctionAbstract::getClosureCalledClass
クロージャ内部で static:: に対応するクラスを返す
&reftitle.description;
public ReflectionClassnullReflectionFunctionAbstract::getClosureCalledClass
Closure 内部で static::
に対応するクラス名に解決されるクラスを、ReflectionClass
として返します。
&reftitle.parameters;
&no.function.parameters;
&reftitle.returnvalues;
Closure 内部で static::
で表現されるクラスに対応する ReflectionClass を返します。
関数がクロージャでないか、グローバルスコープの場合は &null; を返します。
&reftitle.examples;
この例は、オブジェクトコンテキスト内部のクロージャについて、
ReflectionFunctionAbstract::getClosureCalledClass,
ReflectionFunctionAbstract::getClosureScopeClass,
ReflectionFunctionAbstract::getClosureThis
の違いを示しています。
getClosure();
$r = new ReflectionFunction($c);
var_dump($r->getClosureThis()); // $this === $b, since a non-static closure take the object context
var_dump($r->getClosureScopeClass()); // Corresponds to the self::class resolution inside a closure
var_dump($r->getClosureCalledClass()); // Corresponds to the static::class resolution inside a closure
?>
]]>
&example.outputs;
string(1) "A"
}
object(ReflectionClass)#4 (1) {
["name"]=>
string(1) "B"
}
]]>
この例は、オブジェクトコンテキストが存在しない static なクロージャについて、
ReflectionFunctionAbstract::getClosureCalledClass,
ReflectionFunctionAbstract::getClosureScopeClass,
ReflectionFunctionAbstract::getClosureThis
の違いを示しています。
getClosure();
$r = new ReflectionFunction($c);
var_dump($r->getClosureThis()); // NULL, since the pseudo-variable $this is not available in a static context
var_dump($r->getClosureScopeClass()); // Corresponds to the self::class resolution inside a closure
var_dump($r->getClosureCalledClass()); // Corresponds to the static::class resolution inside a closure
?>
]]>
&example.outputs;
string(1) "A"
}
object(ReflectionClass)#4 (1) {
["name"]=>
string(1) "B"
}
]]>
&reftitle.seealso;
ReflectionFunctionAbstract::getClosureScopeClass
ReflectionFunctionAbstract::getClosureThis