1--TEST-- 2Reflection::getClosureThis() 3--FILE-- 4<?php 5class StaticExample 6{ 7 static function foo() 8 { 9 var_dump( "Static Example class, Hello World!" ); 10 } 11} 12 13class Example 14{ 15 public $bar = 42; 16 public function foo() 17 { 18 var_dump( "Example class, bar: " . $this->bar ); 19 } 20} 21 22// Initialize classes 23$class = new ReflectionClass( 'Example' ); 24$staticclass = new ReflectionClass( 'StaticExample' ); 25$object = new Example(); 26 27$method = $staticclass->getMethod( 'foo' ); 28$closure = $method->getClosure(); 29$rf = new ReflectionFunction($closure); 30 31var_dump($rf->getClosureThis()); 32 33$method = $class->getMethod( 'foo' ); 34 35$closure = $method->getClosure( $object ); 36$rf = new ReflectionFunction($closure); 37 38var_dump($rf->getClosureThis()); 39 40echo "Done!\n"; 41?> 42--EXPECTF-- 43NULL 44object(Example)#%d (1) { 45 ["bar"]=> 46 int(42) 47} 48Done! 49