1--TEST-- 2Test ReflectionMethod::getClosure() function : basic functionality 3--FILE-- 4<?php 5echo "*** Testing ReflectionMethod::getClosure() : basic functionality ***\n"; 6 7class StaticExample 8{ 9 static function foo() 10 { 11 var_dump( "Static Example class, Hello World!" ); 12 } 13} 14 15class Example 16{ 17 public $bar = 42; 18 public function foo() 19 { 20 var_dump( "Example class, bar: " . $this->bar ); 21 } 22} 23 24// Initialize classes 25$class = new ReflectionClass( 'Example' ); 26$staticclass = new ReflectionClass( 'StaticExample' ); 27$object = new Example(); 28$fakeobj = new StdClass(); 29 30 31$method = $staticclass->getMethod( 'foo' ); 32$closure = $method->getClosure(); 33$closure(); 34 35$method = $class->getMethod( 'foo' ); 36 37$closure = $method->getClosure( $object ); 38$closure(); 39$object->bar = 34; 40$closure(); 41 42?> 43--EXPECT-- 44*** Testing ReflectionMethod::getClosure() : basic functionality *** 45string(34) "Static Example class, Hello World!" 46string(22) "Example class, bar: 42" 47string(22) "Example class, bar: 34" 48