File tree Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ NAN coerced to other types
3+ --FILE--
4+ <?php
5+
6+ $ nan = fdiv (0 , 0 );
7+ var_dump ($ nan );
8+
9+ function implicit_to_bool (bool $ v ) {
10+ var_dump ($ v );
11+ }
12+ function implicit_to_string (string $ v ) {
13+ var_dump ($ v );
14+ }
15+
16+ implicit_to_bool ($ nan );
17+ implicit_to_string ($ nan );
18+
19+ var_dump ((int ) $ nan );
20+ var_dump ((bool ) $ nan );
21+ var_dump ((string ) $ nan );
22+ var_dump ((array ) $ nan );
23+ var_dump ((object ) $ nan );
24+
25+ $ types = [
26+ 'null ' ,
27+ 'bool ' ,
28+ 'int ' ,
29+ 'string ' ,
30+ 'array ' ,
31+ 'object ' ,
32+ ];
33+
34+ foreach ($ types as $ type ) {
35+ $ nan = fdiv (0 , 0 );
36+ settype ($ nan , $ type );
37+ var_dump ($ nan );
38+ }
39+
40+ ?>
41+ --EXPECTF--
42+ float(NAN)
43+ bool(true)
44+ string(3) "NAN"
45+ int(0)
46+ bool(true)
47+ string(3) "NAN"
48+ array(1) {
49+ [0]=>
50+ float(NAN)
51+ }
52+ object(stdClass)#%d (1) {
53+ ["scalar"]=>
54+ float(NAN)
55+ }
56+ NULL
57+ bool(true)
58+ int(0)
59+ string(3) "NAN"
60+ array(1) {
61+ [0]=>
62+ float(NAN)
63+ }
64+ object(stdClass)#%d (1) {
65+ ["scalar"]=>
66+ float(NAN)
67+ }
You can’t perform that action at this time.
0 commit comments