1--TEST--
2Test floor() function : usage variations - different data types as $value arg
3--INI--
4precision=14
5--FILE--
6<?php
7echo "*** Testing floor() : usage variations ***\n";
8//get an unset variable
9$unset_var = 10;
10unset ($unset_var);
11
12// get a class
13class classA
14{
15}
16
17// heredoc string
18$heredoc = <<<EOT
19abc
20xyz
21EOT;
22
23// get a resource variable
24$fp = fopen(__FILE__, "r");
25
26// unexpected values to be passed to $value argument
27$inputs = array(
28       // null data
29/* 1*/ NULL,
30       null,
31
32       // boolean data
33/* 3*/ true,
34       false,
35       TRUE,
36       FALSE,
37
38       // empty data
39/* 7*/ "",
40       '',
41       array(),
42
43       // string data
44/*10*/ "abcxyz",
45       'abcxyz}',
46       $heredoc,
47
48       // object data
49/*13*/ new classA(),
50
51       // undefined data
52/*14*/ @$undefined_var,
53
54       // unset data
55/*15*/ @$unset_var,
56
57       // resource variable
58/*16*/ $fp
59);
60
61// loop through each element of $inputs to check the behaviour of floor()
62$iterator = 1;
63foreach($inputs as $input) {
64    echo "\n-- Iteration $iterator --\n";
65    try {
66        var_dump(floor($input));
67    } catch (TypeError $e) {
68        echo $e->getMessage(), "\n";
69    }
70    $iterator++;
71};
72fclose($fp);
73?>
74--EXPECTF--
75*** Testing floor() : usage variations ***
76
77-- Iteration 1 --
78
79Deprecated: floor(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
80float(0)
81
82-- Iteration 2 --
83
84Deprecated: floor(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
85float(0)
86
87-- Iteration 3 --
88float(1)
89
90-- Iteration 4 --
91float(0)
92
93-- Iteration 5 --
94float(1)
95
96-- Iteration 6 --
97float(0)
98
99-- Iteration 7 --
100floor(): Argument #1 ($num) must be of type int|float, string given
101
102-- Iteration 8 --
103floor(): Argument #1 ($num) must be of type int|float, string given
104
105-- Iteration 9 --
106floor(): Argument #1 ($num) must be of type int|float, array given
107
108-- Iteration 10 --
109floor(): Argument #1 ($num) must be of type int|float, string given
110
111-- Iteration 11 --
112floor(): Argument #1 ($num) must be of type int|float, string given
113
114-- Iteration 12 --
115floor(): Argument #1 ($num) must be of type int|float, string given
116
117-- Iteration 13 --
118floor(): Argument #1 ($num) must be of type int|float, classA given
119
120-- Iteration 14 --
121
122Deprecated: floor(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
123float(0)
124
125-- Iteration 15 --
126
127Deprecated: floor(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
128float(0)
129
130-- Iteration 16 --
131floor(): Argument #1 ($num) must be of type int|float, resource given
132