xref: /PHP-8.3/ext/reflection/tests/004.phpt (revision f8d79582)
1--TEST--
2ReflectionMethod::invoke() with non object or null value
3--FILE--
4<?php
5
6class a {
7    function __construct(){
8    }
9}
10class b {
11}
12
13$b = new b();
14
15$a=new ReflectionClass("a");
16$m=$a->getMethod("__construct");
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
38?>
39--EXPECT--
40Trying to invoke non static method a::__construct() without an object
41Given object is not an instance of the class this method was declared in
42