xref: /PHP-8.3/ext/reflection/tests/008.phpt (revision f41220fe)
1--TEST--
2ReflectionMethod::__construct() tests
3--FILE--
4<?php
5
6$a = array("", 1, "::", "a::", "::b", "a::b");
7
8foreach ($a as $val) {
9    try {
10        new ReflectionMethod($val);
11    } catch (Exception $e) {
12        var_dump($e->getMessage());
13    }
14
15    try {
16        ReflectionMethod::createFromMethodName($val);
17    } catch (Exception $e) {
18        var_dump($e->getMessage());
19    }
20}
21
22$a = array("", 1, "");
23$b = array("", "", 1);
24
25foreach ($a as $key=>$val) {
26    try {
27        new ReflectionMethod($val, $b[$key]);
28    } catch (Exception $e) {
29        var_dump($e->getMessage());
30    }
31}
32
33echo "Done\n";
34?>
35--EXPECT--
36string(90) "ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name"
37string(91) "ReflectionMethod::createFromMethodName(): Argument #1 ($method) must be a valid method name"
38string(90) "ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name"
39string(91) "ReflectionMethod::createFromMethodName(): Argument #1 ($method) must be a valid method name"
40string(23) "Class "" does not exist"
41string(23) "Class "" does not exist"
42string(24) "Class "a" does not exist"
43string(24) "Class "a" does not exist"
44string(23) "Class "" does not exist"
45string(23) "Class "" does not exist"
46string(24) "Class "a" does not exist"
47string(24) "Class "a" does not exist"
48string(23) "Class "" does not exist"
49string(24) "Class "1" does not exist"
50string(23) "Class "" does not exist"
51Done
52