summaryrefslogtreecommitdiff
path: root/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt
blob: 5c980536b9f9bb501c960901d67581dba0ac166e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
--TEST--
ReflectionMethod constructor errors
--CREDITS--
Robin Fernandes <robinf@php.net>
Steve Seear <stevseea@php.net>
--FILE--
<?php

class TestClass
{
    public function foo() {
    }
}


try {
	echo "\nWrong type of argument (bool):\n";
	$methodInfo = new ReflectionMethod(true);
} catch (Exception $e) {
	print $e->__toString();
}
try {
	echo "\nWrong type of argument (int):\n";
	$methodInfo = new ReflectionMethod(3);
} catch (Exception $e) {
	print $e->__toString();
}
try {
	echo "\nWrong type of argument (bool, string):\n";
	$methodInfo = new ReflectionMethod(true, "foo");
} catch (Exception $e) {
	print $e->__toString();
}
try {
	echo "\nWrong type of argument (string, bool):\n";
	$methodInfo = new ReflectionMethod('TestClass', true);
} catch (Exception $e) {
	print $e->__toString();
}
try {
	echo "\nNo method given:\n";
	$methodInfo = new ReflectionMethod("TestClass");
} catch (Exception $e) {
	print $e->__toString();
}
try {
	echo "\nClass and Method in same string, bad method name:\n";
	$methodInfo = new ReflectionMethod("TestClass::foop::dedoop");
} catch (Exception $e) {
	print $e->__toString();
}
try {
	echo "\nClass and Method in same string, bad class name:\n";
	$methodInfo = new ReflectionMethod("TestCla::foo");
} catch (Exception $e) {
	print $e->__toString();
}
try {
	echo "\nClass and Method in same string (ok):\n";
	$methodInfo = new ReflectionMethod("TestClass::foo");
} catch (Exception $e) {
	print $e->__toString();
}

?>
--EXPECTF--
Wrong type of argument (bool):
ReflectionException: Invalid method name 1 in %s
Stack trace:
#0 %s ReflectionMethod->__construct('1')
#1 {main}
Wrong type of argument (int):
ReflectionException: Invalid method name 3 in %s
Stack trace:
#0 %s ReflectionMethod->__construct('3')
#1 {main}
Wrong type of argument (bool, string):
ReflectionException: The parameter class is expected to be either a string or an object in %s
Stack trace:
#0 %s ReflectionMethod->__construct(true, 'foo')
#1 {main}
Wrong type of argument (string, bool):
ReflectionException: Method TestClass::1() does not exist in %s
Stack trace:
#0 %s ReflectionMethod->__construct('TestClass', '1')
#1 {main}
No method given:
ReflectionException: Invalid method name TestClass in %s
Stack trace:
#0 %s ReflectionMethod->__construct('TestClass')
#1 {main}
Class and Method in same string, bad method name:
ReflectionException: Method TestClass::foop::dedoop() does not exist in %s
Stack trace:
#0 %s ReflectionMethod->__construct('TestClass::foop...')
#1 {main}
Class and Method in same string, bad class name:
ReflectionException: Class TestCla does not exist in %s
Stack trace:
#0 %s ReflectionMethod->__construct('TestCla::foo')
#1 {main}
Class and Method in same string (ok):