xref: /PHP-7.3/ext/reflection/tests/004.phpt (revision f706897f)
1--TEST--
2ReflectionMethod::invoke() with non object or null value
3--FILE--
4<?php
5
6class a {
7	function a(){
8	}
9}
10class b {
11}
12
13$b = new b();
14
15$a=new ReflectionClass("a");
16$m=$a->getMethod("a");
17
18try {
19        $m->invoke(null);
20} catch (ReflectionException $E) {
21        echo $E->getMessage()."\n";
22}
23
24
25try {
26        $m->invoke($b);
27} catch (ReflectionException $E) {
28        echo $E->getMessage()."\n";
29}
30
31$b = new a();
32try {
33        $m->invoke($b);
34} catch (ReflectionException $E) {
35        echo $E->getMessage()."\n";
36}
37
38echo "===DONE===\n";?>
39--EXPECTF--
40Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; a has a deprecated constructor in %s on line %d
41Trying to invoke non static method a::a() without an object
42Given object is not an instance of the class this method was declared in
43===DONE===
44