Skip to content

Commit fd74e27

Browse files
committed
Some test fixes and implementation fixes in SPL and standard
1 parent a871c71 commit fd74e27

13 files changed

+59
-8
lines changed

Zend/tests/array_offset.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ echo "Done\n";
1313
--EXPECTF--
1414
Warning: Undefined array key -1 in %s on line %d
1515

16+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
17+
1618
Warning: Undefined array key -1 in %s on line %d
1719

1820
Warning: Undefined array key -1 in %s on line %d
1921

22+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
23+
2024
Warning: Undefined array key -1 in %s on line %d
2125
Done

Zend/tests/bug72347.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function test() : int {
1212
}
1313
var_dump(test());
1414
?>
15-
--EXPECT--
15+
--EXPECTF--
16+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
1617
float(1.5)
1718
int(1)

Zend/tests/constant_expressions_dynamic.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ var_dump(
4646
?>
4747
--EXPECTF--
4848
Warning: A non-numeric value encountered in %s on line %d
49+
50+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
4951
int(3)
5052
string(4) "1foo"
5153
bool(false)

Zend/tests/empty_str_offset.phpt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var_dump(empty($str[$f]));
6262
print "done\n";
6363

6464
?>
65-
--EXPECT--
65+
--EXPECTF--
6666
- empty ---
6767
bool(false)
6868
bool(true)
@@ -98,14 +98,32 @@ bool(true)
9898
- null ---
9999
bool(false)
100100
- double ---
101+
102+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
101103
bool(false)
104+
105+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
102106
bool(true)
107+
108+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
103109
bool(true)
110+
111+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
104112
bool(false)
113+
114+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
105115
bool(false)
116+
117+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
106118
bool(false)
119+
120+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
107121
bool(false)
122+
123+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
108124
bool(false)
125+
126+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
109127
bool(true)
110128
- array ---
111129
bool(true)

Zend/tests/isset_array.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ try {
3838
bool(true)
3939
bool(true)
4040
bool(true)
41+
42+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
4143
bool(true)
4244
bool(false)
4345
bool(false)

Zend/tests/isset_str_offset.phpt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var_dump(isset($str[$f]));
6060
print "done\n";
6161

6262
?>
63-
--EXPECT--
63+
--EXPECTF--
6464
- isset ---
6565
bool(true)
6666
bool(false)
@@ -95,13 +95,29 @@ bool(false)
9595
- null ---
9696
bool(true)
9797
- double ---
98+
99+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
98100
bool(true)
101+
102+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
99103
bool(false)
104+
105+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
100106
bool(true)
107+
108+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
101109
bool(true)
110+
111+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
102112
bool(true)
113+
114+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
103115
bool(true)
116+
117+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
104118
bool(true)
119+
120+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
105121
bool(false)
106122
- array ---
107123
bool(false)

Zend/tests/list_keyed_conversions.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ list(STDIN => $resource) = [];
2121

2222
?>
2323
--EXPECTF--
24+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
2425
string(0) ""
2526
int(1)
2627
int(0)

Zend/tests/not_001.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ var_dump(bin2hex($s1));
1616

1717
echo "Done\n";
1818
?>
19-
--EXPECT--
19+
--EXPECTF--
20+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
2021
int(-24)
2122
string(8) "8c90929a"
2223
Done

Zend/tests/offset_array.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ echo "Done\n";
3434
?>
3535
--EXPECTF--
3636
int(2)
37+
38+
Deprecated: Implicit conversion to int from non-compatible float in %s on line %d
3739
int(1)
3840

3941
Warning: Undefined array key "" in %s on line %d

Zend/tests/type_declarations/scalar_basic.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Scalar type basics
66
$errnames = [
77
E_NOTICE => 'E_NOTICE',
88
E_WARNING => 'E_WARNING',
9+
E_DEPRECATED => 'E_DEPRECATED'
910
];
1011
set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) {
1112
echo "$errnames[$errno]: $errmsg on line $line\n";
@@ -71,6 +72,7 @@ int(1)
7172
int(1)
7273

7374
*** Trying float(1.5)
75+
E_DEPRECATED: Implicit conversion to int from non-compatible float on line %d
7476
int(1)
7577

7678
*** Trying string(2) "1a"

Zend/tests/type_declarations/scalar_return_basic_64bit.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Return scalar type basics
88
$errnames = [
99
E_NOTICE => 'E_NOTICE',
1010
E_WARNING => 'E_WARNING',
11+
E_DEPRECATED => 'E_DEPRECATED',
1112
];
1213
set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) {
1314
echo "$errnames[$errno]: $errmsg on line $line\n";
@@ -70,6 +71,7 @@ int(1)
7071
*** Trying float(1)
7172
int(1)
7273
*** Trying float(1.5)
74+
E_DEPRECATED: Implicit conversion to int from non-compatible float on line %d
7375
int(1)
7476
*** Trying string(2) "1a"
7577
*** Caught {closure}(): Return value must be of type int, string returned in %s on line %d

Zend/zend_operators.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo
443443
} \
444444
} while (0);
445445

446+
/* TODO Should this warn? */
446447
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op) /* {{{ */
447448
{
448449
zend_long tmp;
@@ -464,13 +465,12 @@ ZEND_API void ZEND_FASTCALL convert_to_long(zval *op) /* {{{ */
464465
case IS_LONG:
465466
break;
466467
case IS_DOUBLE:
467-
ZVAL_LONG(op, zend_dval_to_lval_safe(Z_DVAL_P(op)));
468+
ZVAL_LONG(op, zend_dval_to_lval(Z_DVAL_P(op)));
468469
break;
469470
case IS_STRING:
470471
{
471472
zend_string *str = Z_STR_P(op);
472-
/* zval_get_long will check if float string is integer compatible */
473-
ZVAL_LONG(op, zval_get_long(op));
473+
ZVAL_LONG(op, zval_get_long_ex(op, /* is lax */ true));
474474
zend_string_release_ex(str, 0);
475475
}
476476
break;

ext/spl/spl_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static zend_result get_hash_key(spl_hash_key *key, spl_array_object *intern, zva
310310
break;
311311
case IS_DOUBLE:
312312
key->key = NULL;
313-
key->h = (zend_long) Z_DVAL_P(offset);
313+
key->h = zend_dval_to_lval_safe(Z_DVAL_P(offset));
314314
break;
315315
case IS_FALSE:
316316
key->key = NULL;

0 commit comments

Comments
 (0)