Skip to content

Commit 2211241

Browse files
committed
Fix more 32bits tests
Make some vsprintf not sensible to whitespace output
1 parent 1253271 commit 2211241

27 files changed

+675
-1019
lines changed

Zend/tests/bug46701.phpt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ class foo {
2626
new foo;
2727

2828
?>
29-
--EXPECT--
29+
--EXPECTF--
30+
Deprecated: Implicit conversion from non-compatible float 3428599296 to int in %s on line %d
31+
32+
Deprecated: Implicit conversion from non-compatible float 3459455488 to int in %s on line %d
33+
34+
Deprecated: Implicit conversion from non-compatible float 3459616768 to int in %s on line %d
3035
array(3) {
3136
[-866368000]=>
3237
int(1)
@@ -35,7 +40,11 @@ array(3) {
3540
[-835350528]=>
3641
int(3)
3742
}
43+
44+
Deprecated: Implicit conversion from non-compatible float 3459455488 to int in %s on line %d
3845
int(2)
46+
47+
Deprecated: Implicit conversion from non-compatible float 3459616768 to int in %s on line %d
3948
array(1) {
4049
[-835350528]=>
4150
int(3)

Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
--TEST--
22
Explicit (int) cast must not warn
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6+
?>
37
--FILE--
48
<?php
59

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Explicit (int) cast must not warn 32bit variation
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
$values =[
11+
3.0,
12+
3.5,
13+
10e120,
14+
10e300,
15+
fdiv(0, 0),
16+
(string) 3.0,
17+
(string) 3.5,
18+
(string) 10e120,
19+
(string) 10e300,
20+
(string) fdiv(0, 0),
21+
];
22+
23+
foreach($values as $value) {
24+
var_dump((int) $value);
25+
}
26+
27+
?>
28+
--EXPECT--
29+
int(3)
30+
int(3)
31+
int(0)
32+
int(0)
33+
int(0)
34+
int(3)
35+
int(3)
36+
int(2147483647)
37+
int(2147483647)
38+
int(0)

Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $float = 10e120;
77
$string_float = (string) $float;
88

99
var_dump((int) $float);
10-
var_dump((int) $string_float);
10+
var_dump((int) $string_float === PHP_INT_MAX);
1111

1212
$arrayConstant = [10e120 => 'Large float', (string) 10e120 => 'String large float'];
1313
$arrayDynamic = [$float => 'Large float', $string_float => 'String large float'];
@@ -24,7 +24,7 @@ var_dump($array[$string_float]);
2424
?>
2525
--EXPECTF--
2626
int(0)
27-
int(9223372036854775807)
27+
bool(true)
2828

2929
Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d
3030

Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
--TEST--
22
Implicit float to int conversions when float too large should warn, string offset variant
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6+
?>
37
--FILE--
48
<?php
59

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
--TEST--
2+
Implicit float to int conversions when float too large should warn, string offset variant, 32bit variant
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
$float = 10e120;
11+
$string_float = (string) $float;
12+
13+
var_dump((int) $float);
14+
var_dump((int) $string_float);
15+
16+
$string = 'Here is some text for good measure';
17+
18+
echo 'Attempt to read', \PHP_EOL;
19+
try {
20+
echo 'Float', \PHP_EOL;
21+
var_dump($string[10e120]);
22+
} catch (\TypeError) {
23+
echo 'TypeError', \PHP_EOL;
24+
}
25+
try {
26+
echo 'Float variable', \PHP_EOL;
27+
var_dump($string[$float]);
28+
} catch (\TypeError) {
29+
echo 'TypeError', \PHP_EOL;
30+
}
31+
try {
32+
echo 'Float casted to string compile', \PHP_EOL;
33+
var_dump($string[(string) 10e120]);
34+
} catch (\TypeError) {
35+
echo 'TypeError', \PHP_EOL;
36+
}
37+
try {
38+
echo 'Float string variable', \PHP_EOL;
39+
var_dump($string[$string_float]);
40+
} catch (\TypeError) {
41+
echo 'TypeError', \PHP_EOL;
42+
}
43+
44+
echo 'Attempt to assign', \PHP_EOL;
45+
try {
46+
echo 'Float', \PHP_EOL;
47+
$string[10e120] = 'E';
48+
var_dump($string);
49+
$string = 'Here is some text for good measure';
50+
} catch (\TypeError) {
51+
echo 'TypeError', \PHP_EOL;
52+
}
53+
try {
54+
echo 'Float variable', \PHP_EOL;
55+
$string[$float] = 'E';
56+
var_dump($string);
57+
$string = 'Here is some text for good measure';
58+
} catch (\TypeError) {
59+
echo 'TypeError', \PHP_EOL;
60+
}
61+
62+
try {
63+
$string[(string) 10e120] = 'E';
64+
var_dump($string);
65+
} catch (\TypeError) {
66+
echo 'TypeError', \PHP_EOL;
67+
}
68+
var_dump($string);
69+
try {
70+
$string[$string_float] = 'E';
71+
} catch (\TypeError) {
72+
echo 'TypeError', \PHP_EOL;
73+
}
74+
var_dump($string);
75+
76+
?>
77+
--EXPECTF--
78+
int(0)
79+
int(2147483647)
80+
Attempt to read
81+
Float
82+
83+
Warning: String offset cast occurred in %s on line %d
84+
string(1) "H"
85+
Float variable
86+
87+
Warning: String offset cast occurred in %s on line %d
88+
string(1) "H"
89+
Float casted to string compile
90+
91+
Warning: Uninitialized string offset 2147483647 in %s on line %d
92+
TypeError
93+
Float string variable
94+
95+
Warning: Uninitialized string offset 2147483647 in %s on line %d
96+
TypeError
97+
Attempt to assign
98+
Float
99+
100+
Warning: String offset cast occurred in %s on line %d
101+
string(34) "Eere is some text for good measure"
102+
Float variable
103+
104+
Warning: String offset cast occurred in %s on line %d
105+
string(34) "Eere is some text for good measure"
106+
TypeError
107+
string(34) "Here is some text for good measure"
108+
TypeError
109+
string(34) "Here is some text for good measure"

Zend/tests/type_declarations/scalar_return_basic.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 from non-compatible float 1.5 to int 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/tests/type_declarations/scalar_return_basic_64bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ int(1)
7171
*** Trying float(1)
7272
int(1)
7373
*** Trying float(1.5)
74-
E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line 14
74+
E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line %d
7575
int(1)
7676
*** Trying string(2) "1a"
7777
*** Caught {closure}(): Return value must be of type int, string returned in %s on line %d

ext/openssl/tests/openssl_decrypt_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $password = "openssl";
1010

1111
$ivlen = openssl_cipher_iv_length($method);
1212
$iv = '';
13-
srand(time() + ((microtime(true) * 1000000) % 1000000));
13+
srand(time() + ((int)(microtime(true) * 1000000) % 1000000));
1414
while(strlen($iv) < $ivlen) $iv .= chr(rand(0,255));
1515

1616
$encrypted = openssl_encrypt($data, $method, $password, 0, $iv);

0 commit comments

Comments
 (0)