1--TEST--
2Test ReflectionMethod::getClosure() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : public mixed ReflectionFunction::getClosure()
6 * Description: Returns a dynamically created closure for the method
7 * Source code: ext/reflection/php_reflection.c
8 * Alias to functions:
9 */
10
11echo "*** Testing ReflectionMethod::getClosure() : basic functionality ***\n";
12
13class StaticExample
14{
15	static function foo()
16	{
17		var_dump( "Static Example class, Hello World!" );
18	}
19}
20
21class Example
22{
23	public $bar = 42;
24	public function foo()
25	{
26		var_dump( "Example class, bar: " . $this->bar );
27	}
28}
29
30// Initialize classes
31$class = new ReflectionClass( 'Example' );
32$staticclass = new ReflectionClass( 'StaticExample' );
33$object = new Example();
34$fakeobj = new StdClass();
35
36
37$method = $staticclass->getMethod( 'foo' );
38$closure = $method->getClosure();
39$closure();
40
41$method = $class->getMethod( 'foo' );
42
43$closure = $method->getClosure( $object );
44$closure();
45$object->bar = 34;
46$closure();
47
48?>
49===DONE===
50--EXPECT--
51*** Testing ReflectionMethod::getClosure() : basic functionality ***
52string(34) "Static Example class, Hello World!"
53string(22) "Example class, bar: 42"
54string(22) "Example class, bar: 34"
55===DONE===
56