1--TEST--
2Test array_merge() function : usage variations - Pass different data types to $arr1 arg
3--FILE--
4<?php
5/*
6 * Pass different data types as $arr1 argument to test behaviour
7 */
8
9echo "*** Testing array_merge() : usage variations ***\n";
10
11// Initialise function arguments not being substituted
12$arr2 = array (1, 2);
13
14//get an unset variable
15$unset_var = 10;
16unset ($unset_var);
17
18// get a class
19class classA
20{
21  public function __toString() {
22    return "Class A object";
23  }
24}
25
26// heredoc string
27$heredoc = <<<EOT
28hello world
29EOT;
30
31// get a resource variable
32$fp = fopen(__FILE__, "r");
33
34// unexpected values to be passed to $arr1 argument
35$inputs = array(
36
37       // int data
38/*1*/  0,
39       1,
40       12345,
41       -2345,
42
43       // float data
44/*5*/  10.5,
45       -10.5,
46       12.3456789000e10,
47       12.3456789000E-10,
48       .5,
49
50       // null data
51/*10*/ NULL,
52       null,
53
54       // boolean data
55/*12*/ true,
56       false,
57       TRUE,
58       FALSE,
59
60       // empty data
61/*16*/ "",
62       '',
63       array(),
64
65       // string data
66/*19*/ "string",
67       'string',
68       $heredoc,
69
70       // object data
71/*22*/ new classA(),
72
73       // undefined data
74/*23*/ @$undefined_var,
75
76       // unset data
77/*24*/ @$unset_var,
78
79       // resource variable
80/*25*/ $fp
81);
82
83// loop through each element of $inputs to check the behavior of array_merge()
84$iterator = 1;
85foreach($inputs as $input) {
86  echo "\n-- Iteration $iterator --\n";
87  var_dump( array_merge($input, $arr2) );
88  $iterator++;
89};
90
91fclose($fp);
92
93echo "Done";
94?>
95--EXPECTF--
96*** Testing array_merge() : usage variations ***
97
98-- Iteration 1 --
99
100Fatal error: Uncaught TypeError: array_merge(): Argument #1 must be of type array, int given in %s:%d
101Stack trace:
102#0 %s(%d): array_merge(0, Array)
103#1 {main}
104  thrown in %s on line %d
105