随着PHP 5.3中闭包的引入,在ReflectionFunctionAbstract上引入了一个getClosureThis()方法。
任何人都知道它的用途是什么?文档没有说什么,谷歌到目前为止一直没用,我对不同 ReflectionFunction/ReflectionMethod 对象的尝试都返回了NULL
。
随着PHP 5.3中闭包的引入,在ReflectionFunctionAbstract上引入了一个getClosureThis()方法。
任何人都知道它的用途是什么?文档没有说什么,谷歌到目前为止一直没用,我对不同 ReflectionFunction/ReflectionMethod 对象的尝试都返回了NULL
。
正如它所说:
返回绑定到闭包的 this 指针
所以如果你有 PHP 5.4:
<?php
class MyObj {}
$foo = function() { };
$obj = new MyObj;
$foo = $foo->bindTo($obj); // Inside the newly returned closure, $this == $obj
$reflector = new ReflectionFunction($foo);
assert($obj === $reflector->getClosureThis());
即,它返回闭包的$this
指针。