Skip to content

Commit 656be82

Browse files
committed
1 parent de78eb5 commit 656be82

19 files changed

+201
-85
lines changed

Zend/tests/runtime_compile_time_binary_operands.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
88
?>
99
--FILE--
1010
<?php
11-
error_reporting(E_ALL ^ E_DEPRECATED);
11+
error_reporting(E_ALL ^ E_DEPRECATED ^ E_WARNING);
1212

1313
$binaryOperators = [
1414
"==",

Zend/tests/type_coercion/float_to_int/explicit_casts_should_not_warn.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Explicit (int) cast must not warn
2+
Explicit (int) cast must not warn (except for NAN)
33
--SKIPIF--
44
<?php
55
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
@@ -12,12 +12,10 @@ $values =[
1212
3.5,
1313
10e120,
1414
10e300,
15-
fdiv(0, 0),
1615
(string) 3.0,
1716
(string) 3.5,
1817
(string) 10e120,
1918
(string) 10e300,
20-
(string) fdiv(0, 0),
2119
];
2220

2321
foreach($values as $value) {
@@ -30,9 +28,7 @@ int(3)
3028
int(3)
3129
int(0)
3230
int(0)
33-
int(0)
3431
int(3)
3532
int(3)
3633
int(9223372036854775807)
3734
int(9223372036854775807)
38-
int(0)

Zend/tests/type_coercion/float_to_int/explicit_casts_should_not_warn_32bit.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Explicit (int) cast must not warn 32bit variation
2+
Explicit (int) cast must not warn (except for NAN) 32bit variation
33
--SKIPIF--
44
<?php
55
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
@@ -12,12 +12,10 @@ $values =[
1212
3.5,
1313
10e120,
1414
10e300,
15-
fdiv(0, 0),
1615
(string) 3.0,
1716
(string) 3.5,
1817
(string) 10e120,
1918
(string) 10e300,
20-
(string) fdiv(0, 0),
2119
];
2220

2321
foreach($values as $value) {
@@ -30,9 +28,7 @@ int(3)
3028
int(3)
3129
int(0)
3230
int(0)
33-
int(0)
3431
int(3)
3532
int(3)
3633
int(2147483647)
3734
int(2147483647)
38-
int(0)

Zend/tests/type_coercion/float_to_int/union_int_string_type_arg.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ int(1)
2323

2424
Deprecated: Implicit conversion from float 1.5 to int loses precision in %s on line %d
2525
int(1)
26+
27+
Warning: unexpected NAN value was coerced to string in %s on line %d
2628
string(3) "NAN"
2729
string(8) "1.0E+121"
2830
string(3) "INF"

Zend/tests/type_coercion/int_special_values.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ $values = [
88
-INF,
99
1 / INF,
1010
-1 / INF, // Negative zero,
11-
NAN
1211
];
1312

1413
foreach($values as $value) {
@@ -32,6 +31,3 @@ int(0)
3231

3332
float(-0)
3433
int(0)
35-
36-
float(NAN)
37-
int(0)

Zend/tests/type_coercion/nan_to_other.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,53 @@ foreach ($types as $type) {
4040
?>
4141
--EXPECTF--
4242
float(NAN)
43+
44+
Warning: unexpected NAN value was coerced to bool in %s on line %d
4345
bool(true)
46+
47+
Warning: unexpected NAN value was coerced to string in %s on line %d
4448
string(3) "NAN"
49+
50+
Warning: unexpected NAN value was coerced to int in %s on line %d
4551
int(0)
52+
53+
Warning: unexpected NAN value was coerced to bool in %s on line %d
4654
bool(true)
55+
56+
Warning: unexpected NAN value was coerced to string in %s on line %d
4757
string(3) "NAN"
58+
59+
Warning: unexpected NAN value was coerced to array in %s on line %d
4860
array(1) {
4961
[0]=>
5062
float(NAN)
5163
}
64+
65+
Warning: unexpected NAN value was coerced to object in %s on line %d
5266
object(stdClass)#%d (1) {
5367
["scalar"]=>
5468
float(NAN)
5569
}
70+
71+
Warning: unexpected NAN value was coerced to null in %s on line %d
5672
NULL
73+
74+
Warning: unexpected NAN value was coerced to bool in %s on line %d
5775
bool(true)
76+
77+
Warning: unexpected NAN value was coerced to int in %s on line %d
5878
int(0)
79+
80+
Warning: unexpected NAN value was coerced to string in %s on line %d
5981
string(3) "NAN"
82+
83+
Warning: unexpected NAN value was coerced to array in %s on line %d
6084
array(1) {
6185
[0]=>
6286
float(NAN)
6387
}
88+
89+
Warning: unexpected NAN value was coerced to object in %s on line %d
6490
object(stdClass)#%d (1) {
6591
["scalar"]=>
6692
float(NAN)

Zend/tests/type_declarations/scalar_basic.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ string(0) ""
194194
string(%d) "%d"
195195

196196
*** Trying float(NAN)
197+
E_WARNING: unexpected NAN value was coerced to string on line %d
197198
string(3) "NAN"
198199

199200
*** Trying bool(true)
@@ -247,6 +248,7 @@ bool(false)
247248
bool(true)
248249

249250
*** Trying float(NAN)
251+
E_WARNING: unexpected NAN value was coerced to bool on line %d
250252
bool(true)
251253

252254
*** Trying bool(true)

Zend/tests/type_declarations/scalar_return_basic.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ string(0) ""
156156
*** Trying int(2147483647)
157157
string(10) "2147483647"
158158
*** Trying float(NAN)
159+
E_WARNING: unexpected NAN value was coerced to string on line %d
159160
string(3) "NAN"
160161
*** Trying bool(true)
161162
string(1) "1"
@@ -193,6 +194,7 @@ bool(false)
193194
*** Trying int(2147483647)
194195
bool(true)
195196
*** Trying float(NAN)
197+
E_WARNING: unexpected NAN value was coerced to bool on line %d
196198
bool(true)
197199
*** Trying bool(true)
198200
bool(true)

Zend/tests/type_declarations/scalar_return_basic_64bit.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ string(0) ""
156156
*** Trying int(9223372036854775807)
157157
string(19) "9223372036854775807"
158158
*** Trying float(NAN)
159+
E_WARNING: unexpected NAN value was coerced to string on line %d
159160
string(3) "NAN"
160161
*** Trying bool(true)
161162
string(1) "1"
@@ -193,6 +194,7 @@ bool(false)
193194
*** Trying int(9223372036854775807)
194195
bool(true)
195196
*** Trying float(NAN)
197+
E_WARNING: unexpected NAN value was coerced to bool on line %d
196198
bool(true)
197199
*** Trying bool(true)
198200
bool(true)

Zend/zend_compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10210,6 +10210,7 @@ static void zend_compile_binary_op(znode *result, zend_ast *ast) /* {{{ */
1021010210
}
1021110211

1021210212
do {
10213+
// TODO do not do this for NAN?
1021310214
if (opcode == ZEND_IS_EQUAL || opcode == ZEND_IS_NOT_EQUAL) {
1021410215
if (left_node.op_type == IS_CONST) {
1021510216
if (Z_TYPE(left_node.u.constant) == IS_FALSE) {

0 commit comments

Comments
 (0)