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