1--TEST--
2ReflectionMethod constructor errors
3--CREDITS--
4Robin Fernandes <robinf@php.net>
5Steve Seear <stevseea@php.net>
6--FILE--
7<?php
8
9class TestClass
10{
11    public function foo() {
12    }
13}
14
15
16try {
17    echo "\nWrong type of argument (bool):\n";
18    $methodInfo = new ReflectionMethod(true);
19} catch (Exception $e) {
20    print $e->__toString();
21}
22try {
23    echo "\nWrong type of argument (int):\n";
24    $methodInfo = new ReflectionMethod(3);
25} catch (Exception $e) {
26    print $e->__toString();
27}
28try {
29    echo "\nWrong type of argument (bool, string):\n";
30    $methodInfo = new ReflectionMethod(true, "foo");
31} catch (Exception $e) {
32    print $e->__toString();
33}
34try {
35    echo "\nWrong type of argument (string, bool):\n";
36    $methodInfo = new ReflectionMethod('TestClass', true);
37} catch (Exception $e) {
38    print $e->__toString();
39}
40try {
41    echo "\nNo method given:\n";
42    $methodInfo = new ReflectionMethod("TestClass");
43} catch (Exception $e) {
44    print $e->__toString();
45}
46try {
47    echo "\nClass and Method in same string, bad method name:\n";
48    $methodInfo = new ReflectionMethod("TestClass::foop::dedoop");
49} catch (Exception $e) {
50    print $e->__toString();
51}
52try {
53    echo "\nClass and Method in same string, bad class name:\n";
54    $methodInfo = new ReflectionMethod("TestCla::foo");
55} catch (Exception $e) {
56    print $e->__toString();
57}
58try {
59    echo "\nClass and Method in same string (ok):\n";
60    $methodInfo = new ReflectionMethod("TestClass::foo");
61} catch (Exception $e) {
62    print $e->__toString();
63}
64
65?>
66--EXPECTF--
67Wrong type of argument (bool):
68
69Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
70ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
71Stack trace:
72#0 %s ReflectionMethod->__construct('1')
73#1 {main}
74Wrong type of argument (int):
75
76Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
77ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
78Stack trace:
79#0 %s ReflectionMethod->__construct('3')
80#1 {main}
81Wrong type of argument (bool, string):
82ReflectionException: Class "1" does not exist in %s:%d
83Stack trace:
84#0 %s ReflectionMethod->__construct('1', 'foo')
85#1 {main}
86Wrong type of argument (string, bool):
87ReflectionException: Method TestClass::1() does not exist in %s:%d
88Stack trace:
89#0 %s ReflectionMethod->__construct('TestClass', '1')
90#1 {main}
91No method given:
92
93Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
94ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
95Stack trace:
96#0 %s ReflectionMethod->__construct('TestClass')
97#1 {main}
98Class and Method in same string, bad method name:
99
100Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
101ReflectionException: Method TestClass::foop::dedoop() does not exist in %s:%d
102Stack trace:
103#0 %s ReflectionMethod->__construct('TestClass::foop...')
104#1 {main}
105Class and Method in same string, bad class name:
106
107Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
108ReflectionException: Class "TestCla" does not exist in %s:%d
109Stack trace:
110#0 %s ReflectionMethod->__construct('TestCla::foo')
111#1 {main}
112Class and Method in same string (ok):
113
114Deprecated: Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead in %s on line %d
115