1--TEST--
2Test ReflectionMethod::getClosure() function : error functionality
3--FILE--
4<?php
5echo "*** Testing ReflectionMethod::getClosure() : error conditions ***\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$method = $class->getMethod( 'foo' );
28$staticmethod = $staticclass->getMethod( 'foo' );
29$object = new Example();
30$fakeobj = new StdClass();
31
32echo "\n-- Testing ReflectionMethod::getClosure() function with invalid object --\n";
33try {
34        var_dump( $method->getClosure( $fakeobj ) );
35} catch( Exception $e ) {
36        var_dump( $e->getMessage() );
37}
38
39?>
40--EXPECT--
41*** Testing ReflectionMethod::getClosure() : error conditions ***
42
43-- Testing ReflectionMethod::getClosure() function with invalid object --
44string(72) "Given object is not an instance of the class this method was declared in"
45