1--TEST--
2Test method_exists() function : usage variations  - unexpected type for arg 1
3--FILE--
4<?php
5spl_autoload_register(function ($className) {
6    echo "In autoload($className)\n";
7});
8
9function test_error_handler($err_no, $err_msg, $filename, $linenum) {
10    echo "Error: $err_no - $err_msg\n";
11}
12set_error_handler('test_error_handler');
13
14echo "*** Testing method_exists() : usage variations ***\n";
15
16// Initialise function arguments not being substituted (if any)
17$method = 'string_val';
18
19//get an unset variable
20$unset_var = 10;
21unset ($unset_var);
22
23//array of values to iterate over
24$values = array(
25
26      // int data
27      0,
28      1,
29      12345,
30      -2345,
31
32      // float data
33      10.5,
34      -10.5,
35      10.1234567e10,
36      10.7654321E-10,
37      .5,
38
39      // array data
40      array(),
41      array(0),
42      array(1),
43      array(1, 2),
44      array('color' => 'red', 'item' => 'pen'),
45
46      // null data
47      NULL,
48      null,
49
50      // boolean data
51      true,
52      false,
53      TRUE,
54      FALSE,
55
56      // empty data
57      "",
58      '',
59
60      // string data
61      "string",
62      'String',
63
64      // undefined data
65      $undefined_var,
66
67      // unset data
68      $unset_var,
69);
70
71// loop through each element of the array for object
72
73foreach($values as $value) {
74      echo "\nArg value $value \n";
75      try {
76        var_dump( method_exists($value, $method) );
77      } catch (TypeError $e) {
78        echo $e->getMessage(), PHP_EOL;
79      }
80};
81
82echo "Done";
83?>
84--EXPECT--
85*** Testing method_exists() : usage variations ***
86Error: 2 - Undefined variable $undefined_var
87Error: 2 - Undefined variable $unset_var
88
89Arg value 0
90method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
91
92Arg value 1
93method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
94
95Arg value 12345
96method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
97
98Arg value -2345
99method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
100
101Arg value 10.5
102method_exists(): Argument #1 ($object_or_class) must be of type object|string, float given
103
104Arg value -10.5
105method_exists(): Argument #1 ($object_or_class) must be of type object|string, float given
106
107Arg value 101234567000
108method_exists(): Argument #1 ($object_or_class) must be of type object|string, float given
109
110Arg value 1.07654321E-9
111method_exists(): Argument #1 ($object_or_class) must be of type object|string, float given
112
113Arg value 0.5
114method_exists(): Argument #1 ($object_or_class) must be of type object|string, float given
115Error: 2 - Array to string conversion
116
117Arg value Array
118method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given
119Error: 2 - Array to string conversion
120
121Arg value Array
122method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given
123Error: 2 - Array to string conversion
124
125Arg value Array
126method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given
127Error: 2 - Array to string conversion
128
129Arg value Array
130method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given
131Error: 2 - Array to string conversion
132
133Arg value Array
134method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given
135
136Arg value
137method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
138
139Arg value
140method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
141
142Arg value 1
143method_exists(): Argument #1 ($object_or_class) must be of type object|string, bool given
144
145Arg value
146method_exists(): Argument #1 ($object_or_class) must be of type object|string, bool given
147
148Arg value 1
149method_exists(): Argument #1 ($object_or_class) must be of type object|string, bool given
150
151Arg value
152method_exists(): Argument #1 ($object_or_class) must be of type object|string, bool given
153
154Arg value
155bool(false)
156
157Arg value
158bool(false)
159
160Arg value string
161In autoload(string)
162bool(false)
163
164Arg value String
165In autoload(String)
166bool(false)
167
168Arg value
169method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
170
171Arg value
172method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
173Done
174