Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)

RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
This commit is contained in:
George Peter BanyardandNikita Popov authored and GitHub committed 2021-05-31 15:48:45 +01:00
1 parent e006fd4220
commit b6958bb847
132 files changed
+2268 -2037

No files matched your search

+5 -5
View File
@@ -119,12 +119,12 @@ constant_binary_op:
} else if (opline->extended_value == ZEND_MOD
|| opline->extended_value == ZEND_SL
|| opline->extended_value == ZEND_SR) {
if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_LONG) {
/* don't optimize if it should produce a runtime numeric string error */
if (!(Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING
&& !is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, NULL, 0))) {
convert_to_long(&ZEND_OP2_LITERAL(opline));
zval *op2 = &ZEND_OP2_LITERAL(opline);
if (Z_TYPE_P(op2) != IS_LONG) {
if (!zend_is_op_long_compatible(op2)) {
break;
}
convert_to_long(op2);
}
} else if (opline->extended_value == ZEND_CONCAT) {
if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_STRING) {
+21 -6
View File
@@ -425,9 +425,14 @@ static inline int fetch_array_elem(zval **result, zval *op1, zval *op2) {
case IS_LONG:
*result = zend_hash_index_find(Z_ARR_P(op1), Z_LVAL_P(op2));
return SUCCESS;
case IS_DOUBLE:
*result = zend_hash_index_find(Z_ARR_P(op1), zend_dval_to_lval(Z_DVAL_P(op2)));
case IS_DOUBLE: {
zend_long lval = zend_dval_to_lval(Z_DVAL_P(op2));
if (!zend_is_long_compatible(Z_DVAL_P(op2), lval)) {
return FAILURE;
}
*result = zend_hash_index_find(Z_ARR_P(op1), lval);
return SUCCESS;
}
case IS_STRING:
*result = zend_symtable_find(Z_ARR_P(op1), Z_STR_P(op2));
return SUCCESS;
@@ -508,9 +513,14 @@ static inline int ct_eval_del_array_elem(zval *result, zval *key) {
case IS_LONG:
zend_hash_index_del(Z_ARR_P(result), Z_LVAL_P(key));
break;
case IS_DOUBLE:
zend_hash_index_del(Z_ARR_P(result), zend_dval_to_lval(Z_DVAL_P(key)));
case IS_DOUBLE: {
zend_long lval = zend_dval_to_lval(Z_DVAL_P(key));
if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) {
return FAILURE;
}
zend_hash_index_del(Z_ARR_P(result), lval);
break;
}
case IS_STRING:
zend_symtable_del(Z_ARR_P(result), Z_STR_P(key));
break;
@@ -548,11 +558,16 @@ static inline int ct_eval_add_array_elem(zval *result, zval *value, zval *key) {
SEPARATE_ARRAY(result);
value = zend_hash_index_update(Z_ARR_P(result), Z_LVAL_P(key), value);
break;
case IS_DOUBLE:
case IS_DOUBLE: {
zend_long lval = zend_dval_to_lval(Z_DVAL_P(key));
if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) {
return FAILURE;
}
SEPARATE_ARRAY(result);
value = zend_hash_index_update(
Z_ARR_P(result), zend_dval_to_lval(Z_DVAL_P(key)), value);
Z_ARR_P(result), lval, value);
break;
}
case IS_STRING:
SEPARATE_ARRAY(result);
value = zend_symtable_update(Z_ARR_P(result), Z_STR_P(key), value);
+13 -6
View File
@@ -4481,7 +4481,6 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op,
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
case ZEND_DIV:
case ZEND_MOD:
if (!OP2_HAS_RANGE() ||
(OP2_MIN_RANGE() <= 0 && OP2_MAX_RANGE() >= 0)) {
/* Division by zero */
@@ -4493,10 +4492,18 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op,
case ZEND_POW:
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
/* Ops may throw if not an integer */
case ZEND_MOD:
if (!OP2_HAS_RANGE() ||
(OP2_MIN_RANGE() <= 0 && OP2_MAX_RANGE() >= 0)) {
/* Division by zero */
return 1;
}
ZEND_FALLTHROUGH;
case ZEND_SL:
case ZEND_SR:
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
return (t1 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
!OP2_HAS_RANGE() ||
OP2_MIN_RANGE() < 0;
case ZEND_CONCAT:
@@ -4510,10 +4517,10 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op,
&& (t2 & MAY_BE_ANY) == MAY_BE_STRING) {
return 0;
}
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
return (t1 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
case ZEND_BW_NOT:
return (t1 & (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
return (t1 & (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
case ZEND_PRE_INC:
case ZEND_POST_INC:
case ZEND_PRE_DEC:
+4
View File
@@ -13,9 +13,13 @@ echo "Done\n";
--EXPECTF--
Warning: Undefined array key -1 in %s on line %d
Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d
Warning: Undefined array key -1 in %s on line %d
Warning: Undefined array key -1 in %s on line %d
Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d
Warning: Undefined array key -1 in %s on line %d
Done
+10 -1
View File
@@ -26,7 +26,12 @@ class foo {
new foo;
?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit conversion from non-compatible float 3428599296 to int in %s on line %d
Deprecated: Implicit conversion from non-compatible float 3459455488 to int in %s on line %d
Deprecated: Implicit conversion from non-compatible float 3459616768 to int in %s on line %d
array(3) {
[-866368000]=>
int(1)
@@ -35,7 +40,11 @@ array(3) {
[-835350528]=>
int(3)
}
Deprecated: Implicit conversion from non-compatible float 3459455488 to int in %s on line %d
int(2)
Deprecated: Implicit conversion from non-compatible float 3459616768 to int in %s on line %d
array(1) {
[-835350528]=>
int(3)
+2 -1
View File
@@ -12,6 +12,7 @@ function test() : int {
}
var_dump(test());
?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
float(1.5)
int(1)
@@ -46,6 +46,8 @@ var_dump(
?>
--EXPECTF--
Warning: A non-numeric value encountered in %s on line %d
Deprecated: Implicit conversion from non-compatible float 3.14 to int in %s on line %d
int(3)
string(4) "1foo"
bool(false)
+19 -1
View File
@@ -62,7 +62,7 @@ var_dump(empty($str[$f]));
print "done\n";
?>
--EXPECT--
--EXPECTF--
- empty ---
bool(false)
bool(true)
@@ -98,14 +98,32 @@ bool(true)
- null ---
bool(false)
- double ---
Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d
bool(false)
Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d
bool(true)
Deprecated: Implicit conversion from non-compatible float -4.1 to int in %s on line %d
bool(true)
Deprecated: Implicit conversion from non-compatible float -0.8 to int in %s on line %d
bool(false)
Deprecated: Implicit conversion from non-compatible float -0.1 to int in %s on line %d
bool(false)
Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d
bool(false)
Deprecated: Implicit conversion from non-compatible float 0.9 to int in %s on line %d
bool(false)
Deprecated: Implicit conversion from non-compatible float 3.141592653589793 to int in %s on line %d
bool(false)
Deprecated: Implicit conversion from non-compatible float 100.5001 to int in %s on line %d
bool(true)
- array ---
bool(true)
@@ -0,0 +1,38 @@
--TEST--
Explicit (int) cast must not warn
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
<?php
$values =[
3.0,
3.5,
10e120,
10e300,
fdiv(0, 0),
(string) 3.0,
(string) 3.5,
(string) 10e120,
(string) 10e300,
(string) fdiv(0, 0),
];
foreach($values as $value) {
var_dump((int) $value);
}
?>
--EXPECT--
int(3)
int(3)
int(0)
int(0)
int(0)
int(3)
int(3)
int(9223372036854775807)
int(9223372036854775807)
int(0)
@@ -0,0 +1,38 @@
--TEST--
Explicit (int) cast must not warn 32bit variation
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php
$values =[
3.0,
3.5,
10e120,
10e300,
fdiv(0, 0),
(string) 3.0,
(string) 3.5,
(string) 10e120,
(string) 10e300,
(string) fdiv(0, 0),
];
foreach($values as $value) {
var_dump((int) $value);
}
?>
--EXPECT--
int(3)
int(3)
int(0)
int(0)
int(0)
int(3)
int(3)
int(2147483647)
int(2147483647)
int(0)
@@ -0,0 +1,15 @@
--TEST--
Negative 0 check
--FILE--
<?php
$negativeZero = -0.0;
var_dump($negativeZero);
var_dump($negativeZero === (float)(int)$negativeZero);
var_dump($negativeZero === 0.0);
?>
--EXPECT--
float(-0)
bool(true)
bool(true)
@@ -0,0 +1,93 @@
--TEST--
Implicit float to int conversions should not warn for literals if float has a fractional part equal to 0
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$var = ~1.0;
var_dump($var);
$var = 1.0|3;
var_dump($var);
$var = 1.0&3;
var_dump($var);
$var = 1.0^3;
var_dump($var);
$var = 1.0 << 3;
var_dump($var);
$var = 1.0 >> 3;
var_dump($var);
$var = 3 << 1.0;
var_dump($var);
$var = 3 >> 1.0;
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$var = 6.0 % 2;
var_dump($var);
$var = 9 % 2.0;
var_dump($var);
echo 'Offset access:' . \PHP_EOL;
echo 'Arrays:' . \PHP_EOL;
$array = ['a', 'b', 'c'];
var_dump($array[1.0]);
$array[2.0] = 'z';
var_dump($array);
/* Strings are handled differently and always warn on non integer keys */
echo 'Function calls:' . \PHP_EOL;
function foo(int $a) {
return $a;
}
var_dump(foo(1.0));
var_dump(chr(60.0));
echo 'Function returns:' . \PHP_EOL;
function bar(): int {
return 3.0;
}
var_dump(bar());
echo 'Typed property assignment:' . \PHP_EOL;
class Test {
public int $a;
}
$instance = new Test();
$instance->a = 1.0;
var_dump($instance->a);
?>
--EXPECT--
Bitwise ops:
int(-2)
int(3)
int(1)
int(2)
int(8)
int(0)
int(6)
int(1)
Modulo:
int(0)
int(1)
Offset access:
Arrays:
string(1) "b"
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "z"
}
Function calls:
int(1)
string(1) "<"
Function returns:
int(3)
Typed property assignment:
int(1)
@@ -0,0 +1,73 @@
--TEST--
Implicit string float to int conversions should not warn for literals if float has a fractional part equal to 0
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$var = '1.0'|3;
var_dump($var);
$var = '1.0'&3;
var_dump($var);
$var = '1.0'^3;
var_dump($var);
$var = '1.0' << 3;
var_dump($var);
$var = '1.0' >> 3;
var_dump($var);
$var = 3 << '1.0';
var_dump($var);
$var = 3 >> '1.0';
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$var = '6.0' % 2;
var_dump($var);
$var = 9 % '2.0';
var_dump($var);
/* Float string array keys are never normalized to an integer value */
/* Strings are handled differently and always warn on non integer keys */
echo 'Function calls:' . \PHP_EOL;
function foo(int $a) {
return $a;
}
var_dump(foo('1.0'));
var_dump(chr('60.0'));
echo 'Function returns:' . \PHP_EOL;
function bar(): int {
return '3.0';
}
var_dump(bar());
echo 'Typed property assignment:' . \PHP_EOL;
class Test {
public int $a;
}
$instance = new Test();
$instance->a = '1.0';
var_dump($instance->a);
?>
--EXPECT--
Bitwise ops:
int(3)
int(1)
int(2)
int(8)
int(0)
int(6)
int(1)
Modulo:
int(0)
int(1)
Function calls:
int(1)
string(1) "<"
Function returns:
int(3)
Typed property assignment:
int(1)
@@ -0,0 +1,42 @@
--TEST--
Implicit float to int conversions should not warn for literals in combined assingment operetor if float has a fractional part equal to 0
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$var = 3;
$var |= 1.0;
var_dump($var);
$var = 3;
$var &= 1.0;
var_dump($var);
$var = 3;
$var ^= 1.0;
var_dump($var);
$var = 3;
$var <<= 1.0;
var_dump($var);
$var = 3;
$var >>= 1.0;
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$var = 9;
$var %= 2.0;
var_dump($var);
?>
--EXPECT--
Bitwise ops:
int(3)
int(1)
int(2)
int(6)
int(1)
Modulo:
int(1)
@@ -0,0 +1,117 @@
--TEST--
Implicit float to int conversions should not warn for variables if float has a fractional part equal to 0
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$float = 1.0;
$var = ~$float;
var_dump($var);
$var = $float|3;
var_dump($var);
$var = $float&3;
var_dump($var);
$var = $float^3;
var_dump($var);
$var = $float << 3;
var_dump($var);
$var = $float >> 3;
var_dump($var);
$var = $float;
$var <<= 3;
var_dump($var);
$var = $float;
$var >>= 3;
var_dump($var);
$var = 3 << $float;
var_dump($var);
$var = 3 >> $float;
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$modFloat = 6.0;
$var = $modFloat % 2;
var_dump($var);
$modFloat = 2.0;
$var = 9 % $modFloat;
var_dump($var);
echo 'Offset access:' . \PHP_EOL;
$offsetAccess = 2.0;
echo 'Arrays:' . \PHP_EOL;
$array = ['a', 'b', 'c'];
var_dump($array[$float]);
$array[$offsetAccess] = 'z';
var_dump($array);
echo 'Function calls:' . \PHP_EOL;
function foo(int $a) {
return $a;
}
var_dump(foo($float));
$cp = 60.0;
var_dump(chr($cp));
echo 'Function returns:' . \PHP_EOL;
function bar(): int {
$var = 3.0;
return $var;
}
var_dump(bar());
echo 'Typed property assignment:' . \PHP_EOL;
class Test {
public int $a;
}
$instance = new Test();
$instance->a = $float;
var_dump($instance->a);
?>
--EXPECT--
Bitwise ops:
int(-2)
int(3)
int(1)
int(2)
int(8)
int(0)
int(8)
int(0)
int(6)
int(1)
Modulo:
int(0)
int(1)
Offset access:
Arrays:
string(1) "b"
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "z"
}
Function calls:
int(1)
string(1) "<"
Function returns:
int(3)
Typed property assignment:
int(1)
@@ -0,0 +1,94 @@
--TEST--
Implicit string float to int conversions should not warn for variables if float has a fractional part equal to 0
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$float = '1.0';
$var = $float|3;
var_dump($var);
$var = $float&3;
var_dump($var);
$var = $float^3;
var_dump($var);
$var = $float << 3;
var_dump($var);
$var = $float >> 3;
var_dump($var);
$var = $float;
$var <<= 3;
var_dump($var);
$var = $float;
$var >>= 3;
var_dump($var);
$var = 3 << $float;
var_dump($var);
$var = 3 >> $float;
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$modFloat = '6.0';
$var = $modFloat % 2;
var_dump($var);
$modFloat = '2.0';
$var = 9 % $modFloat;
var_dump($var);
echo 'Function calls:' . \PHP_EOL;
function foo(int $a) {
return $a;
}
var_dump(foo($float));
$cp = '60.0';
var_dump(chr($cp));
echo 'Function returns:' . \PHP_EOL;
function bar(): int {
$var = '3.0';
return $var;
}
var_dump(bar());
echo 'Typed property assignment:' . \PHP_EOL;
class Test {
public int $a;
}
$instance = new Test();
$instance->a = $float;
var_dump($instance->a);
?>
--EXPECT--
Bitwise ops:
int(3)
int(1)
int(2)
int(8)
int(0)
int(8)
int(0)
int(6)
int(1)
Modulo:
int(0)
int(1)
Function calls:
int(1)
string(1) "<"
Function returns:
int(3)
Typed property assignment:
int(1)
@@ -0,0 +1,28 @@
--TEST--
Union of int|string shouldn't warn if string semantics are used
--FILE--
<?php
$float = 1.0;
function foo(int|string $a): void {
var_dump($a);
}
foo(1.0);
foo(1.5);
foo(fdiv(0, 0));
foo(10e120);
foo(10e500); // Infinity
?>
--EXPECTF--
int(1)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
string(3) "NAN"
string(8) "1.0E+121"
string(3) "INF"
@@ -0,0 +1,55 @@
--TEST--
Implicit float to int conversions when float too large should warn, array variant
--FILE--
<?php
$float = 10e120;
$string_float = (string) $float;
var_dump((int) $float);
var_dump((int) $string_float === PHP_INT_MAX);
$arrayConstant = [10e120 => 'Large float', (string) 10e120 => 'String large float'];
$arrayDynamic = [$float => 'Large float', $string_float => 'String large float'];
var_dump($arrayConstant);
var_dump($arrayDynamic);
$array = ['0', '1', '2'];
var_dump($array[10e120]);
var_dump($array[(string) 10e120]);
var_dump($array[$float]);
var_dump($array[$string_float]);
?>
--EXPECTF--
int(0)
bool(true)
Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d
Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d
array(2) {
[0]=>
string(11) "Large float"
["1.0E+121"]=>
string(18) "String large float"
}
array(2) {
[0]=>
string(11) "Large float"
["1.0E+121"]=>
string(18) "String large float"
}
Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d
string(1) "0"
Warning: Undefined array key "1.0E+121" in %s on line %d
NULL
Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d
string(1) "0"
Warning: Undefined array key "1.0E+121" in %s on line %d
NULL
@@ -0,0 +1,109 @@
--TEST--
Implicit float to int conversions when float too large should warn, string offset variant
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
<?php
$float = 10e120;
$string_float = (string) $float;
var_dump((int) $float);
var_dump((int) $string_float);
$string = 'Here is some text for good measure';
echo 'Attempt to read', \PHP_EOL;
try {
echo 'Float', \PHP_EOL;
var_dump($string[10e120]);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
echo 'Float variable', \PHP_EOL;
var_dump($string[$float]);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
echo 'Float casted to string compile', \PHP_EOL;
var_dump($string[(string) 10e120]);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
echo 'Float string variable', \PHP_EOL;
var_dump($string[$string_float]);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
echo 'Attempt to assign', \PHP_EOL;
try {
echo 'Float', \PHP_EOL;
$string[10e120] = 'E';
var_dump($string);
$string = 'Here is some text for good measure';
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
echo 'Float variable', \PHP_EOL;
$string[$float] = 'E';
var_dump($string);
$string = 'Here is some text for good measure';
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
$string[(string) 10e120] = 'E';
var_dump($string);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
var_dump($string);
try {
$string[$string_float] = 'E';
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
var_dump($string);
?>
--EXPECTF--
int(0)
int(9223372036854775807)
Attempt to read
Float
Warning: String offset cast occurred in %s on line %d
string(1) "H"
Float variable
Warning: String offset cast occurred in %s on line %d
string(1) "H"
Float casted to string compile
Warning: Uninitialized string offset 9223372036854775807 in %s on line %d
TypeError
Float string variable
Warning: Uninitialized string offset 9223372036854775807 in %s on line %d
TypeError
Attempt to assign
Float
Warning: String offset cast occurred in %s on line %d
string(34) "Eere is some text for good measure"
Float variable
Warning: String offset cast occurred in %s on line %d
string(34) "Eere is some text for good measure"
TypeError
string(34) "Here is some text for good measure"
TypeError
string(34) "Here is some text for good measure"
@@ -0,0 +1,109 @@
--TEST--
Implicit float to int conversions when float too large should warn, string offset variant, 32bit variant
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php
$float = 10e120;
$string_float = (string) $float;
var_dump((int) $float);
var_dump((int) $string_float);
$string = 'Here is some text for good measure';
echo 'Attempt to read', \PHP_EOL;
try {
echo 'Float', \PHP_EOL;
var_dump($string[10e120]);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
echo 'Float variable', \PHP_EOL;
var_dump($string[$float]);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
echo 'Float casted to string compile', \PHP_EOL;
var_dump($string[(string) 10e120]);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
echo 'Float string variable', \PHP_EOL;
var_dump($string[$string_float]);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
echo 'Attempt to assign', \PHP_EOL;
try {
echo 'Float', \PHP_EOL;
$string[10e120] = 'E';
var_dump($string);
$string = 'Here is some text for good measure';
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
echo 'Float variable', \PHP_EOL;
$string[$float] = 'E';
var_dump($string);
$string = 'Here is some text for good measure';
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
try {
$string[(string) 10e120] = 'E';
var_dump($string);
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
var_dump($string);
try {
$string[$string_float] = 'E';
} catch (\TypeError) {
echo 'TypeError', \PHP_EOL;
}
var_dump($string);
?>
--EXPECTF--
int(0)
int(2147483647)
Attempt to read
Float
Warning: String offset cast occurred in %s on line %d
string(1) "H"
Float variable
Warning: String offset cast occurred in %s on line %d
string(1) "H"
Float casted to string compile
Warning: Uninitialized string offset 2147483647 in %s on line %d
TypeError
Float string variable
Warning: Uninitialized string offset 2147483647 in %s on line %d
TypeError
Attempt to assign
Float
Warning: String offset cast occurred in %s on line %d
string(34) "Eere is some text for good measure"
Float variable
Warning: String offset cast occurred in %s on line %d
string(34) "Eere is some text for good measure"
TypeError
string(34) "Here is some text for good measure"
TypeError
string(34) "Here is some text for good measure"
@@ -0,0 +1,140 @@
--TEST--
Implicit float to int conversions should warn for literals
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
// 8 Warnings generated in total
$var = ~1.5;
var_dump($var);
$var = 1.5|3;
var_dump($var);
$var = 1.5&3;
var_dump($var);
$var = 1.5^3;
var_dump($var);
$var = 1.5 << 3;
var_dump($var);
$var = 1.5 >> 3;
var_dump($var);
$var = 3 << 1.5;
var_dump($var);
$var = 3 >> 1.5;
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
// 2 warnings in total
$var = 6.5 % 2;
var_dump($var);
$var = 9 % 2.5;
var_dump($var);
echo 'Offset access:' . \PHP_EOL;
echo 'Arrays:' . \PHP_EOL;
// 2 warnings in total
$array = ['a', 'b', 'c'];
var_dump($array[1.5]);
$array[2.5] = 'z';
var_dump($array);
echo 'Strings:' . \PHP_EOL;
// 2 warnings in total
$string = 'php';
var_dump($string[1.5]);
$string[2.5] = 'z';
var_dump($string);
echo 'Function calls:' . \PHP_EOL;
function foo(int $a) {
return $a;
}
var_dump(foo(1.5));
var_dump(chr(60.5));
echo 'Function returns:' . \PHP_EOL;
function bar(): int {
return 3.5;
}
var_dump(bar());
echo 'Typed property assignment:' . \PHP_EOL;
class Test {
public int $a;
}
$instance = new Test();
$instance->a = 1.5;
var_dump($instance->a);
?>
--EXPECTF--
Bitwise ops:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(-2)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(3)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(2)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(8)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(6)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
Modulo:
Deprecated: Implicit conversion from non-compatible float 6.5 to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d
int(1)
Offset access:
Arrays:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
string(1) "b"
Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "z"
}
Strings:
Warning: String offset cast occurred in %s on line %d
string(1) "h"
Warning: String offset cast occurred in %s on line %d
string(3) "phz"
Function calls:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float 60.5 to int in %s on line %d
string(1) "<"
Function returns:
Deprecated: Implicit conversion from non-compatible float 3.5 to int in %s on line %d
int(3)
Typed property assignment:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
@@ -0,0 +1,54 @@
--TEST--
Implicit float to int conversions should warn for literals in combined assingment operetor
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$var = 3;
$var |= 1.5;
var_dump($var);
$var = 3;
$var &= 1.5;
var_dump($var);
$var = 3;
$var ^= 1.5;
var_dump($var);
$var = 3;
$var <<= 1.5;
var_dump($var);
$var = 3;
$var >>= 1.5;
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$var = 9;
$var %= 2.5;
var_dump($var);
?>
--EXPECTF--
Bitwise ops:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(3)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(2)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(6)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
Modulo:
Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d
int(1)
@@ -0,0 +1,168 @@
--TEST--
Implicit float to int conversions should warn for variables
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$float = 1.5;
$var = ~$float;
var_dump($var);
$var = $float|3;
var_dump($var);
$var = $float&3;
var_dump($var);
$var = $float^3;
var_dump($var);
$var = $float << 3;
var_dump($var);
$var = $float >> 3;
var_dump($var);
$var = $float;
$var <<= 3;
var_dump($var);
$var = $float;
$var >>= 3;
var_dump($var);
$var = 3 << $float;
var_dump($var);
$var = 3 >> $float;
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$modFloat = 6.5;
$var = $modFloat % 2;
var_dump($var);
$modFloat = 2.5;
$var = 9 % $modFloat;
var_dump($var);
echo 'Offset access:' . \PHP_EOL;
$offsetAccess = 2.5;
echo 'Arrays:' . \PHP_EOL;
// 2 warnings in total
$array = ['a', 'b', 'c'];
var_dump($array[$float]);
$array[$offsetAccess] = 'z';
var_dump($array);
echo 'Strings:' . \PHP_EOL;
// 2 warnings in total
$string = 'php';
var_dump($string[$float]);
$string[$offsetAccess] = 'z';
var_dump($string);
echo 'Function calls:' . \PHP_EOL;
function foo(int $a) {
return $a;
}
var_dump(foo($float));
$cp = 60.5;
var_dump(chr($cp));
echo 'Function returns:' . \PHP_EOL;
function bar(): int {
$var = 3.5;
return $var;
}
var_dump(bar());
echo 'Typed property assignment:' . \PHP_EOL;
class Test {
public int $a;
}
$instance = new Test();
$instance->a = $float;
var_dump($instance->a);
?>
--EXPECTF--
Bitwise ops:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(-2)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(3)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(2)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(8)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(8)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(6)
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
Modulo:
Deprecated: Implicit conversion from non-compatible float 6.5 to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d
int(1)
Offset access:
Arrays:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
string(1) "b"
Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "z"
}
Strings:
Warning: String offset cast occurred in %s on line %d
string(1) "h"
Warning: String offset cast occurred in %s on line %d
string(3) "phz"
Function calls:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float 60.5 to int in %s on line %d
string(1) "<"
Function returns:
Deprecated: Implicit conversion from non-compatible float 3.5 to int in %s on line %d
int(3)
Typed property assignment:
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
int(1)
@@ -0,0 +1,98 @@
--TEST--
Implicit string float to int conversions should warn for literals
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
// 7 Warnings generated in total
$var = '1.5'|3;
var_dump($var);
$var = '1.5'&3;
var_dump($var);
$var = '1.5'^3;
var_dump($var);
$var = '1.5' << 3;
var_dump($var);
$var = '1.5' >> 3;
var_dump($var);
$var = 3 << '1.5';
var_dump($var);
$var = 3 >> '1.5';
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
// 2 warnings in total
$var = '6.5' % 2;
var_dump($var);
$var = 9 % '2.5';
var_dump($var);
echo 'Function calls:' . \PHP_EOL;
function foo(int $a) {
return $a;
}
var_dump(foo('1.5'));
var_dump(chr('60.5'));
echo 'Function returns:' . \PHP_EOL;
function bar(): int {
return '3.5';
}
var_dump(bar());
echo 'Typed property assignment:' . \PHP_EOL;
class Test {
public int $a;
}
$instance = new Test();
$instance->a = '1.5';
var_dump($instance->a);
?>
--EXPECTF--
Bitwise ops:
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(3)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(2)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(8)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(6)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
Modulo:
Deprecated: Implicit conversion from non-compatible float-string "6.5" to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float-string "2.5" to int in %s on line %d
int(1)
Function calls:
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float-string "60.5" to int in %s on line %d
string(1) "<"
Function returns:
Deprecated: Implicit conversion from non-compatible float-string "3.5" to int in %s on line %d
int(3)
Typed property assignment:
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
@@ -0,0 +1,54 @@
--TEST--
Implicit float to int conversions should warn for literals in combined assingment operetor
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$var = 3;
$var |= '1.5';
var_dump($var);
$var = 3;
$var &= '1.5';
var_dump($var);
$var = 3;
$var ^= '1.5';
var_dump($var);
$var = 3;
$var <<= '1.5';
var_dump($var);
$var = 3;
$var >>= '1.5';
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$var = 9;
$var %= '2.5';
var_dump($var);
?>
--EXPECTF--
Bitwise ops:
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(3)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(2)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(6)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
Modulo:
Deprecated: Implicit conversion from non-compatible float-string "2.5" to int in %s on line %d
int(1)
@@ -0,0 +1,124 @@
--TEST--
Implicit float string to int conversions should warn for variables
--FILE--
<?php
echo 'Bitwise ops:' . \PHP_EOL;
$float = '1.5';
$var = $float|3;
var_dump($var);
$var = $float&3;
var_dump($var);
$var = $float^3;
var_dump($var);
$var = $float << 3;
var_dump($var);
$var = $float >> 3;
var_dump($var);
$var = $float;
$var <<= 3;
var_dump($var);
$var = $float;
$var >>= 3;
var_dump($var);
$var = 3 << $float;
var_dump($var);
$var = 3 >> $float;
var_dump($var);
echo 'Modulo:' . \PHP_EOL;
$modFloat = '6.5';
$var = $modFloat % 2;
var_dump($var);
$modFloat = '2.5';
$var = 9 % $modFloat;
var_dump($var);
echo 'Function calls:' . \PHP_EOL;
function foo(int $a) {
return $a;
}
var_dump(foo($float));
$cp = '60.5';
var_dump(chr($cp));
echo 'Function returns:' . \PHP_EOL;
function bar(): int {
$var = '3.5';
return $var;
}
var_dump(bar());
echo 'Typed property assignment:' . \PHP_EOL;
class Test {
public int $a;
}
$instance = new Test();
$instance->a = $float;
var_dump($instance->a);
?>
--EXPECTF--
Bitwise ops:
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(3)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(2)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(8)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(8)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(6)
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
Modulo:
Deprecated: Implicit conversion from non-compatible float-string "6.5" to int in %s on line %d
int(0)
Deprecated: Implicit conversion from non-compatible float-string "2.5" to int in %s on line %d
int(1)
Function calls:
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
Deprecated: Implicit conversion from non-compatible float-string "60.5" to int in %s on line %d
string(1) "<"
Function returns:
Deprecated: Implicit conversion from non-compatible float-string "3.5" to int in %s on line %d
int(3)
Typed property assignment:
Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d
int(1)
+2
View File
@@ -38,6 +38,8 @@ try {
bool(true)
bool(true)
bool(true)
Deprecated: Implicit conversion from non-compatible float 0.6 to int in %s on line %d
bool(true)
bool(false)
bool(false)
+17 -1
View File
@@ -60,7 +60,7 @@ var_dump(isset($str[$f]));
print "done\n";
?>
--EXPECT--
--EXPECTF--
- isset ---
bool(true)
bool(false)
@@ -95,13 +95,29 @@ bool(false)
- null ---
bool(true)
- double ---
Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d
bool(true)
Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d
bool(false)
Deprecated: Implicit conversion from non-compatible float -0.8 to int in %s on line %d
bool(true)
Deprecated: Implicit conversion from non-compatible float -0.1 to int in %s on line %d
bool(true)
Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d
bool(true)
Deprecated: Implicit conversion from non-compatible float 0.9 to int in %s on line %d
bool(true)
Deprecated: Implicit conversion from non-compatible float 3.141592653589793 to int in %s on line %d
bool(true)
Deprecated: Implicit conversion from non-compatible float 100.5001 to int in %s on line %d
bool(false)
- array ---
bool(false)
+1
View File
@@ -21,6 +21,7 @@ list(STDIN => $resource) = [];
?>
--EXPECTF--
Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d
string(0) ""
int(1)
int(0)
+2 -1
View File
@@ -16,7 +16,8 @@ var_dump(bin2hex($s1));
echo "Done\n";
?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit conversion from non-compatible float 23.67 to int in %s on line %d
int(-24)
string(8) "8c90929a"
Done
+2
View File
@@ -34,6 +34,8 @@ echo "Done\n";
?>
--EXPECTF--
int(2)
Deprecated: Implicit conversion from non-compatible float 0.0836 to int in %s on line %d
int(1)
Warning: Undefined array key "" in %s on line %d
+44 -2
View File
@@ -31,13 +31,13 @@ $legalValues = [
'true',
'false',
'2',
'3.5',
'3.5', // Semi-legal for certain ops
'"123"',
'"123foo"', // Semi-legal
];
set_error_handler(function($errno, $errstr) {
assert($errno == E_WARNING);
assert($errno == E_WARNING || $errno == E_DEPRECATED);
echo "Warning: $errstr\n";
});
@@ -453,6 +453,7 @@ Unsupported operand types: bool % array
Unsupported operand types: array % int
Unsupported operand types: int % array
Unsupported operand types: array % float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float % array
Unsupported operand types: array % string
Unsupported operand types: string % array
@@ -468,6 +469,7 @@ Unsupported operand types: bool % stdClass
Unsupported operand types: stdClass % int
Unsupported operand types: int % stdClass
Unsupported operand types: stdClass % float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float % stdClass
Unsupported operand types: stdClass % string
Unsupported operand types: string % stdClass
@@ -483,6 +485,7 @@ Unsupported operand types: bool % resource
Unsupported operand types: resource % int
Unsupported operand types: int % resource
Unsupported operand types: resource % float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float % resource
Unsupported operand types: resource % string
Unsupported operand types: string % resource
@@ -498,6 +501,7 @@ Unsupported operand types: bool % string
Unsupported operand types: string % int
Unsupported operand types: int % string
Unsupported operand types: string % float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float % string
Unsupported operand types: string % string
Unsupported operand types: string % string
@@ -605,6 +609,7 @@ Unsupported operand types: bool << array
Unsupported operand types: array << int
Unsupported operand types: int << array
Unsupported operand types: array << float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float << array
Unsupported operand types: array << string
Unsupported operand types: string << array
@@ -620,6 +625,7 @@ Unsupported operand types: bool << stdClass
Unsupported operand types: stdClass << int
Unsupported operand types: int << stdClass
Unsupported operand types: stdClass << float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float << stdClass
Unsupported operand types: stdClass << string
Unsupported operand types: string << stdClass
@@ -635,6 +641,7 @@ Unsupported operand types: bool << resource
Unsupported operand types: resource << int
Unsupported operand types: int << resource
Unsupported operand types: resource << float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float << resource
Unsupported operand types: resource << string
Unsupported operand types: string << resource
@@ -650,6 +657,7 @@ Unsupported operand types: bool << string
Unsupported operand types: string << int
Unsupported operand types: int << string
Unsupported operand types: string << float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float << string
Unsupported operand types: string << string
Unsupported operand types: string << string
@@ -681,6 +689,7 @@ Unsupported operand types: bool >> array
Unsupported operand types: array >> int
Unsupported operand types: int >> array
Unsupported operand types: array >> float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float >> array
Unsupported operand types: array >> string
Unsupported operand types: string >> array
@@ -696,6 +705,7 @@ Unsupported operand types: bool >> stdClass
Unsupported operand types: stdClass >> int
Unsupported operand types: int >> stdClass
Unsupported operand types: stdClass >> float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float >> stdClass
Unsupported operand types: stdClass >> string
Unsupported operand types: string >> stdClass
@@ -711,6 +721,7 @@ Unsupported operand types: bool >> resource
Unsupported operand types: resource >> int
Unsupported operand types: int >> resource
Unsupported operand types: resource >> float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float >> resource
Unsupported operand types: resource >> string
Unsupported operand types: string >> resource
@@ -726,6 +737,7 @@ Unsupported operand types: bool >> string
Unsupported operand types: string >> int
Unsupported operand types: int >> string
Unsupported operand types: string >> float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float >> string
Unsupported operand types: string >> string
Unsupported operand types: string >> string
@@ -757,6 +769,7 @@ Unsupported operand types: bool & array
Unsupported operand types: array & int
Unsupported operand types: int & array
Unsupported operand types: array & float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float & array
Unsupported operand types: array & string
Unsupported operand types: string & array
@@ -800,6 +813,7 @@ Unsupported operand types: bool & string
Unsupported operand types: string & int
Unsupported operand types: int & string
Unsupported operand types: string & float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float & string
No error for "foo" & "123"
No error for "123" & "foo"
@@ -830,6 +844,7 @@ Unsupported operand types: bool | array
Unsupported operand types: array | int
Unsupported operand types: int | array
Unsupported operand types: array | float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float | array
Unsupported operand types: array | string
Unsupported operand types: string | array
@@ -873,6 +888,7 @@ Unsupported operand types: bool | string
Unsupported operand types: string | int
Unsupported operand types: int | string
Unsupported operand types: string | float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float | string
No error for "foo" | "123"
No error for "123" | "foo"
@@ -903,6 +919,7 @@ Unsupported operand types: bool ^ array
Unsupported operand types: array ^ int
Unsupported operand types: int ^ array
Unsupported operand types: array ^ float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float ^ array
Unsupported operand types: array ^ string
Unsupported operand types: string ^ array
@@ -946,6 +963,7 @@ Unsupported operand types: bool ^ string
Unsupported operand types: string ^ int
Unsupported operand types: int ^ string
Unsupported operand types: string ^ float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float ^ string
No error for "foo" ^ "123"
No error for "123" ^ "foo"
@@ -1449,6 +1467,7 @@ Unsupported operand types: bool % array
Unsupported operand types: array % int
Unsupported operand types: int % array
Unsupported operand types: array % float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float % array
Unsupported operand types: array % string
Unsupported operand types: string % array
@@ -1464,6 +1483,7 @@ Unsupported operand types: bool % stdClass
Unsupported operand types: stdClass % int
Unsupported operand types: int % stdClass
Unsupported operand types: stdClass % float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float % stdClass
Unsupported operand types: stdClass % string
Unsupported operand types: string % stdClass
@@ -1479,6 +1499,7 @@ Unsupported operand types: bool % resource
Unsupported operand types: resource % int
Unsupported operand types: int % resource
Unsupported operand types: resource % float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float % resource
Unsupported operand types: resource % string
Unsupported operand types: string % resource
@@ -1494,6 +1515,7 @@ Unsupported operand types: bool % string
Unsupported operand types: string % int
Unsupported operand types: int % string
Unsupported operand types: string % float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float % string
Unsupported operand types: string % string
Unsupported operand types: string % string
@@ -1601,6 +1623,7 @@ Unsupported operand types: bool << array
Unsupported operand types: array << int
Unsupported operand types: int << array
Unsupported operand types: array << float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float << array
Unsupported operand types: array << string
Unsupported operand types: string << array
@@ -1616,6 +1639,7 @@ Unsupported operand types: bool << stdClass
Unsupported operand types: stdClass << int
Unsupported operand types: int << stdClass
Unsupported operand types: stdClass << float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float << stdClass
Unsupported operand types: stdClass << string
Unsupported operand types: string << stdClass
@@ -1631,6 +1655,7 @@ Unsupported operand types: bool << resource
Unsupported operand types: resource << int
Unsupported operand types: int << resource
Unsupported operand types: resource << float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float << resource
Unsupported operand types: resource << string
Unsupported operand types: string << resource
@@ -1646,6 +1671,7 @@ Unsupported operand types: bool << string
Unsupported operand types: string << int
Unsupported operand types: int << string
Unsupported operand types: string << float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float << string
Unsupported operand types: string << string
Unsupported operand types: string << string
@@ -1677,6 +1703,7 @@ Unsupported operand types: bool >> array
Unsupported operand types: array >> int
Unsupported operand types: int >> array
Unsupported operand types: array >> float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float >> array
Unsupported operand types: array >> string
Unsupported operand types: string >> array
@@ -1692,6 +1719,7 @@ Unsupported operand types: bool >> stdClass
Unsupported operand types: stdClass >> int
Unsupported operand types: int >> stdClass
Unsupported operand types: stdClass >> float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float >> stdClass
Unsupported operand types: stdClass >> string
Unsupported operand types: string >> stdClass
@@ -1707,6 +1735,7 @@ Unsupported operand types: bool >> resource
Unsupported operand types: resource >> int
Unsupported operand types: int >> resource
Unsupported operand types: resource >> float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float >> resource
Unsupported operand types: resource >> string
Unsupported operand types: string >> resource
@@ -1722,6 +1751,7 @@ Unsupported operand types: bool >> string
Unsupported operand types: string >> int
Unsupported operand types: int >> string
Unsupported operand types: string >> float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float >> string
Unsupported operand types: string >> string
Unsupported operand types: string >> string
@@ -1753,6 +1783,7 @@ Unsupported operand types: bool & array
Unsupported operand types: array & int
Unsupported operand types: int & array
Unsupported operand types: array & float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float & array
Unsupported operand types: array & string
Unsupported operand types: string & array
@@ -1768,6 +1799,7 @@ Unsupported operand types: bool & stdClass
Unsupported operand types: stdClass & int
Unsupported operand types: int & stdClass
Unsupported operand types: stdClass & float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float & stdClass
Unsupported operand types: stdClass & string
Unsupported operand types: string & stdClass
@@ -1783,6 +1815,7 @@ Unsupported operand types: bool & resource
Unsupported operand types: resource & int
Unsupported operand types: int & resource
Unsupported operand types: resource & float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float & resource
Unsupported operand types: resource & string
Unsupported operand types: string & resource
@@ -1798,6 +1831,7 @@ Unsupported operand types: bool & string
Unsupported operand types: string & int
Unsupported operand types: int & string
Unsupported operand types: string & float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float & string
No error for "foo" &= "123"
No error for "123" &= "foo"
@@ -1828,6 +1862,7 @@ Unsupported operand types: bool | array
Unsupported operand types: array | int
Unsupported operand types: int | array
Unsupported operand types: array | float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float | array
Unsupported operand types: array | string
Unsupported operand types: string | array
@@ -1843,6 +1878,7 @@ Unsupported operand types: bool | stdClass
Unsupported operand types: stdClass | int
Unsupported operand types: int | stdClass
Unsupported operand types: stdClass | float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float | stdClass
Unsupported operand types: stdClass | string
Unsupported operand types: string | stdClass
@@ -1858,6 +1894,7 @@ Unsupported operand types: bool | resource
Unsupported operand types: resource | int
Unsupported operand types: int | resource
Unsupported operand types: resource | float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float | resource
Unsupported operand types: resource | string
Unsupported operand types: string | resource
@@ -1873,6 +1910,7 @@ Unsupported operand types: bool | string
Unsupported operand types: string | int
Unsupported operand types: int | string
Unsupported operand types: string | float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float | string
No error for "foo" |= "123"
No error for "123" |= "foo"
@@ -1903,6 +1941,7 @@ Unsupported operand types: bool ^ array
Unsupported operand types: array ^ int
Unsupported operand types: int ^ array
Unsupported operand types: array ^ float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float ^ array
Unsupported operand types: array ^ string
Unsupported operand types: string ^ array
@@ -1918,6 +1957,7 @@ Unsupported operand types: bool ^ stdClass
Unsupported operand types: stdClass ^ int
Unsupported operand types: int ^ stdClass
Unsupported operand types: stdClass ^ float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float ^ stdClass
Unsupported operand types: stdClass ^ string
Unsupported operand types: string ^ stdClass
@@ -1933,6 +1973,7 @@ Unsupported operand types: bool ^ resource
Unsupported operand types: resource ^ int
Unsupported operand types: int ^ resource
Unsupported operand types: resource ^ float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float ^ resource
Unsupported operand types: resource ^ string
Unsupported operand types: string ^ resource
@@ -1948,6 +1989,7 @@ Unsupported operand types: bool ^ string
Unsupported operand types: string ^ int
Unsupported operand types: int ^ string
Unsupported operand types: string ^ float
Warning: Implicit conversion from non-compatible float 3.5 to int
Unsupported operand types: float ^ string
No error for "foo" ^= "123"
No error for "123" ^= "foo"
@@ -6,6 +6,7 @@ Scalar type basics
$errnames = [
E_NOTICE => 'E_NOTICE',
E_WARNING => 'E_WARNING',
E_DEPRECATED => 'E_DEPRECATED'
];
set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) {
echo "$errnames[$errno]: $errmsg on line $line\n";
@@ -71,6 +72,7 @@ int(1)
int(1)
*** Trying float(1.5)
E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line 14
int(1)
*** Trying string(2) "1a"
@@ -8,6 +8,7 @@ Return scalar type basics
$errnames = [
E_NOTICE => 'E_NOTICE',
E_WARNING => 'E_WARNING',
E_DEPRECATED => 'E_DEPRECATED',
];
set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) {
echo "$errnames[$errno]: $errmsg on line $line\n";
@@ -70,6 +71,7 @@ int(1)
*** Trying float(1)
int(1)
*** Trying float(1.5)
E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line %d
int(1)
*** Trying string(2) "1a"
*** Caught {closure}(): Return value must be of type int, string returned in %s on line %d
@@ -8,6 +8,7 @@ Return scalar type basics
$errnames = [
E_NOTICE => 'E_NOTICE',
E_WARNING => 'E_WARNING',
E_DEPRECATED => 'E_DEPRECATED',
];
set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) {
echo "$errnames[$errno]: $errmsg on line $line\n";
@@ -70,6 +71,7 @@ int(1)
*** Trying float(1)
int(1)
*** Trying float(1.5)
E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line %d
int(1)
*** Trying string(2) "1a"
*** Caught {closure}(): Return value must be of type int, string returned in %s on line %d
+28 -4
View File
@@ -503,7 +503,18 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest,
if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg)))) {
return 0;
} else {
*dest = zend_dval_to_lval(Z_DVAL_P(arg));
zend_long lval = zend_dval_to_lval(Z_DVAL_P(arg));
if (UNEXPECTED(!zend_is_long_compatible(Z_DVAL_P(arg), lval))) {
/* Check arg_num is not (uint32_t)-1, as otherwise its called by
* zend_verify_weak_scalar_type_hint_no_sideeffect() */
if (arg_num != (uint32_t)-1) {
zend_incompatible_double_to_long_error(Z_DVAL_P(arg));
}
if (UNEXPECTED(EG(exception))) {
return 0;
}
}
*dest = lval;
}
} else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
double d;
@@ -511,14 +522,27 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest,
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
if (EXPECTED(type != 0)) {
zend_long lval;
if (UNEXPECTED(zend_isnan(d))) {
return 0;
}
if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(d))) {
return 0;
} else {
*dest = zend_dval_to_lval(d);
}
lval = zend_dval_to_lval(d);
/* This only checks for a fractional part as if doesn't fit it already throws a TypeError */
if (UNEXPECTED(!zend_is_long_compatible(d, lval))) {
/* Check arg_num is not (uint32_t)-1, as otherwise its called by
* zend_verify_weak_scalar_type_hint_no_sideeffect() */
if (arg_num != (uint32_t)-1) {
zend_incompatible_string_to_long_error(Z_STR_P(arg));
}
if (UNEXPECTED(EG(exception))) {
return 0;
}
}
*dest = lval;
} else {
return 0;
}
@@ -1971,7 +1995,7 @@ ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /
result = zend_hash_index_update(ht, Z_LVAL_P(key), value);
break;
case IS_DOUBLE:
result = zend_hash_index_update(ht, zend_dval_to_lval(Z_DVAL_P(key)), value);
result = zend_hash_index_update(ht, zend_dval_to_lval_safe(Z_DVAL_P(key)), value);
break;
default:
zend_type_error("Illegal offset type");
+1 -1
View File
@@ -465,7 +465,7 @@ static zend_result zend_ast_add_array_element(zval *result, zval *offset, zval *
zend_hash_index_update(Z_ARRVAL_P(result), 1, expr);
break;
case IS_DOUBLE:
zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_lval(Z_DVAL_P(offset)), expr);
zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_lval_safe(Z_DVAL_P(offset)), expr);
break;
case IS_RESOURCE:
zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(offset), Z_RES_HANDLE_P(offset));
+39 -4
View File
@@ -8156,6 +8156,28 @@ static bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */
}
/* }}} */
ZEND_API bool zend_is_op_long_compatible(zval *op)
{
if (Z_TYPE_P(op) == IS_ARRAY) {
return false;
}
if (Z_TYPE_P(op) == IS_DOUBLE
&& !zend_is_long_compatible(Z_DVAL_P(op), zend_dval_to_lval(Z_DVAL_P(op)))) {
return false;
}
if (Z_TYPE_P(op) == IS_STRING) {
double dval = 0;
zend_uchar is_num = is_numeric_str_function(Z_STR_P(op), NULL, &dval);
if (is_num == 0 || (is_num == IS_DOUBLE && !zend_is_long_compatible(dval, zend_dval_to_lval(dval)))) {
return false;
}
}
return true;
}
ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op2) /* {{{ */
{
if ((opcode == ZEND_CONCAT || opcode == ZEND_FAST_CONCAT)) {
@@ -8207,6 +8229,12 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op
return 1;
}
/* Operation which cast float/float-strings to integers might produce incompatible float to int errors */
if (opcode == ZEND_SL || opcode == ZEND_SR || opcode == ZEND_BW_OR
|| opcode == ZEND_BW_AND || opcode == ZEND_BW_XOR || opcode == ZEND_MOD) {
return !zend_is_op_long_compatible(op1) || !zend_is_op_long_compatible(op2);
}
return 0;
}
/* }}} */
@@ -8226,7 +8254,7 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva
ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op)
{
if (opcode == ZEND_BW_NOT) {
return Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY;
return Z_TYPE_P(op) <= IS_TRUE || !zend_is_op_long_compatible(op);
}
return 0;
@@ -8353,10 +8381,17 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
case IS_STRING:
zend_symtable_update(Z_ARRVAL_P(result), Z_STR_P(key), value);
break;
case IS_DOUBLE:
zend_hash_index_update(Z_ARRVAL_P(result),
zend_dval_to_lval(Z_DVAL_P(key)), value);
case IS_DOUBLE: {
zend_long lval = zend_dval_to_lval(Z_DVAL_P(key));
/* Incompatible float will generate an error, leave this to run-time */
if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) {
zval_ptr_dtor_nogc(value);
zval_ptr_dtor(result);
return 0;
}
zend_hash_index_update(Z_ARRVAL_P(result), lval, value);
break;
}
case IS_FALSE:
zend_hash_index_update(Z_ARRVAL_P(result), 0, value);
break;
+1
View File
@@ -1162,6 +1162,7 @@ END_EXTERN_C()
/* The default value for CG(compiler_options) during eval() */
#define ZEND_COMPILE_DEFAULT_FOR_EVAL 0
ZEND_API bool zend_is_op_long_compatible(zval *op);
ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op2);
ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op);
+12 -10
View File
@@ -775,16 +775,18 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask,
double dval;
bool bval;
if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval, 0)) {
/* Pass (uint32_t)-1 as arg_num to indicate to ZPP not to emit any deprecation notice,
* this is needed because the version with side effects also uses 0 (e.g. for typed properties) */
if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval, (uint32_t)-1)) {
return 1;
}
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, 0)) {
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, (uint32_t)-1)) {
return 1;
}
if ((type_mask & MAY_BE_STRING) && can_convert_to_string(arg)) {
return 1;
}
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, 0)) {
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, (uint32_t)-1)) {
return 1;
}
return 0;
@@ -1470,7 +1472,7 @@ try_again:
break;
}
offset = zval_get_long_func(dim);
offset = zval_get_long_func(dim, /* is_strict */ false);
} else {
offset = Z_LVAL_P(dim);
}
@@ -2133,7 +2135,7 @@ static zend_never_inline zend_uchar slow_index_convert(HashTable *ht, const zval
value->str = ZSTR_EMPTY_ALLOC();
return IS_STRING;
case IS_DOUBLE:
value->lval = zend_dval_to_lval(Z_DVAL_P(dim));
value->lval = zend_dval_to_lval_safe(Z_DVAL_P(dim));
return IS_LONG;
case IS_RESOURCE:
zend_use_resource_as_offset(dim);
@@ -2452,7 +2454,7 @@ try_string_offset:
break;
}
offset = zval_get_long_func(dim);
offset = zval_get_long_func(dim, /* is_strict */ false);
} else {
offset = Z_LVAL_P(dim);
}
@@ -2543,7 +2545,7 @@ static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable
zend_ulong hval;
if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
num_idx:
return zend_hash_index_find(ht, hval);
} else if (Z_TYPE_P(offset) == IS_NULL) {
@@ -2597,7 +2599,7 @@ str_offset:
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
lval = zval_get_long_ex(offset, /* is_strict */ true);
goto str_offset;
}
return 0;
@@ -2636,7 +2638,7 @@ str_offset:
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
lval = zval_get_long_ex(offset, /* is_strict */ true);
goto str_offset;
}
return 1;
@@ -2667,7 +2669,7 @@ num_key:
key = Z_REFVAL_P(key);
goto try_again;
} else if (Z_TYPE_P(key) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(key));
hval = zend_dval_to_lval_safe(Z_DVAL_P(key));
goto num_key;
} else if (Z_TYPE_P(key) == IS_FALSE) {
hval = 0;
+57 -9
View File
@@ -303,8 +303,17 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo
return 0;
case IS_TRUE:
return 1;
case IS_DOUBLE:
return zend_dval_to_lval(Z_DVAL_P(op));
case IS_DOUBLE: {
double dval = Z_DVAL_P(op);
zend_long lval = zend_dval_to_lval(dval);
if (!zend_is_long_compatible(dval, lval)) {
zend_incompatible_double_to_long_error(dval);
if (UNEXPECTED(EG(exception))) {
*failed = 1;
}
}
return lval;
}
case IS_STRING:
{
zend_uchar type;
@@ -333,7 +342,14 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo
* We use use saturating conversion to emulate strtol()'s
* behaviour.
*/
return zend_dval_to_lval_cap(dval);
lval = zend_dval_to_lval_cap(dval);
if (!zend_is_long_compatible(dval, lval)) {
zend_incompatible_string_to_long_error(Z_STR_P(op));
if (UNEXPECTED(EG(exception))) {
*failed = 1;
}
}
return lval;
}
}
case IS_OBJECT:
@@ -792,7 +808,16 @@ try_again:
}
/* }}} */
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */
ZEND_API void ZEND_COLD zend_incompatible_double_to_long_error(double d)
{
zend_error_unchecked(E_DEPRECATED, "Implicit conversion from non-compatible float %.*H to int", -1, d);
}
ZEND_API void ZEND_COLD zend_incompatible_string_to_long_error(const zend_string *s)
{
zend_error(E_DEPRECATED, "Implicit conversion from non-compatible float-string \"%s\" to int", ZSTR_VAL(s));
}
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* {{{ */
{
try_again:
switch (Z_TYPE_P(op)) {
@@ -806,8 +831,16 @@ try_again:
return Z_RES_HANDLE_P(op);
case IS_LONG:
return Z_LVAL_P(op);
case IS_DOUBLE:
return zend_dval_to_lval(Z_DVAL_P(op));
case IS_DOUBLE: {
double dval = Z_DVAL_P(op);
zend_long lval = zend_dval_to_lval(dval);
if (UNEXPECTED(is_strict)) {
if (!zend_is_long_compatible(dval, lval)) {
zend_incompatible_double_to_long_error(dval);
}
}
return lval;
}
case IS_STRING:
{
zend_uchar type;
@@ -823,7 +856,14 @@ try_again:
* We use saturating conversion to emulate strtol()'s
* behaviour.
*/
return zend_dval_to_lval_cap(dval);
/* Most usages are expected to not be (int) casts */
lval = zend_dval_to_lval_cap(dval);
if (UNEXPECTED(is_strict)) {
if (!zend_is_long_compatible(dval, lval)) {
zend_incompatible_string_to_long_error(Z_STR_P(op));
}
}
return lval;
}
}
case IS_ARRAY:
@@ -1455,9 +1495,17 @@ try_again:
case IS_LONG:
ZVAL_LONG(result, ~Z_LVAL_P(op1));
return SUCCESS;
case IS_DOUBLE:
ZVAL_LONG(result, ~zend_dval_to_lval(Z_DVAL_P(op1)));
case IS_DOUBLE: {
zend_long lval = zend_dval_to_lval(Z_DVAL_P(op1));
if (!zend_is_long_compatible(Z_DVAL_P(op1), lval)) {
zend_incompatible_double_to_long_error(Z_DVAL_P(op1));
if (EG(exception)) {
return FAILURE;
}
}
ZVAL_LONG(result, ~lval);
return SUCCESS;
}
case IS_STRING: {
size_t i;
+22 -2
View File
@@ -122,6 +122,7 @@ static zend_always_inline zend_long zend_dval_to_lval(double d)
}
#endif
/* Used to convert a string float to integer during an (int) cast */
static zend_always_inline zend_long zend_dval_to_lval_cap(double d)
{
if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
@@ -133,6 +134,22 @@ static zend_always_inline zend_long zend_dval_to_lval_cap(double d)
}
/* }}} */
static zend_always_inline bool zend_is_long_compatible(double d, zend_long l) {
return (double)l == d;
}
ZEND_API void zend_incompatible_double_to_long_error(double d);
ZEND_API void zend_incompatible_string_to_long_error(const zend_string *s);
static zend_always_inline zend_long zend_dval_to_lval_safe(double d)
{
zend_long l = zend_dval_to_lval(d);
if (!zend_is_long_compatible(d, l)) {
zend_incompatible_double_to_long_error(d);
}
return l;
}
#define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
#define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
@@ -267,13 +284,16 @@ ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_array(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_object(zval *op);
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op);
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict);
ZEND_API double ZEND_FASTCALL zval_get_double_func(zval *op);
ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op);
ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op);
static zend_always_inline zend_long zval_get_long(zval *op) {
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op);
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, false);
}
static zend_always_inline zend_long zval_get_long_ex(zval *op, bool is_strict) {
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, is_strict);
}
static zend_always_inline double zval_get_double(zval *op) {
return EXPECTED(Z_TYPE_P(op) == IS_DOUBLE) ? Z_DVAL_P(op) : zval_get_double_func(op);
+3 -3
View File
@@ -5937,7 +5937,7 @@ ZEND_VM_C_LABEL(num_index):
str = ZSTR_EMPTY_ALLOC();
ZEND_VM_C_GOTO(str_index);
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
ZEND_VM_C_GOTO(num_index);
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -6420,7 +6420,7 @@ ZEND_VM_C_LABEL(num_index_dim):
offset = Z_REFVAL_P(offset);
ZEND_VM_C_GOTO(offset_again);
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
ZEND_VM_C_GOTO(num_index_dim);
} else if (Z_TYPE_P(offset) == IS_NULL) {
key = ZSTR_EMPTY_ALLOC();
@@ -9613,7 +9613,7 @@ ZEND_VM_C_LABEL(fetch_dim_r_index_array):
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
offset = Z_LVAL_P(dim);
} else {
offset = zval_get_long(dim);
offset = zval_get_long_ex(dim, /* is_strict */ true);
}
ht = Z_ARRVAL_P(container);
ZEND_HASH_INDEX_FIND(ht, offset, value, ZEND_VM_C_LABEL(fetch_dim_r_index_undef));
+27 -27
View File
@@ -7128,7 +7128,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -8307,7 +8307,7 @@ fetch_dim_r_index_array:
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
offset = Z_LVAL_P(dim);
} else {
offset = zval_get_long(dim);
offset = zval_get_long_ex(dim, /* is_strict */ true);
}
ht = Z_ARRVAL_P(container);
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -9321,7 +9321,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -10241,7 +10241,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -11670,7 +11670,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -16101,7 +16101,7 @@ fetch_dim_r_index_array:
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
offset = Z_LVAL_P(dim);
} else {
offset = zval_get_long(dim);
offset = zval_get_long_ex(dim, /* is_strict */ true);
}
ht = Z_ARRVAL_P(container);
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -16153,7 +16153,7 @@ fetch_dim_r_index_array:
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
offset = Z_LVAL_P(dim);
} else {
offset = zval_get_long(dim);
offset = zval_get_long_ex(dim, /* is_strict */ true);
}
ht = Z_ARRVAL_P(container);
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -19620,7 +19620,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -20059,7 +20059,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -20519,7 +20519,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -20918,7 +20918,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -24437,7 +24437,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -24526,7 +24526,7 @@ num_index_dim:
offset = Z_REFVAL_P(offset);
goto offset_again;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index_dim;
} else if (Z_TYPE_P(offset) == IS_NULL) {
key = ZSTR_EMPTY_ALLOC();
@@ -26612,7 +26612,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -26701,7 +26701,7 @@ num_index_dim:
offset = Z_REFVAL_P(offset);
goto offset_again;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index_dim;
} else if (Z_TYPE_P(offset) == IS_NULL) {
key = ZSTR_EMPTY_ALLOC();
@@ -28469,7 +28469,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -30612,7 +30612,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -30701,7 +30701,7 @@ num_index_dim:
offset = Z_REFVAL_P(offset);
goto offset_again;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index_dim;
} else if (Z_TYPE_P(offset) == IS_NULL) {
key = ZSTR_EMPTY_ALLOC();
@@ -41855,7 +41855,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -41944,7 +41944,7 @@ num_index_dim:
offset = Z_REFVAL_P(offset);
goto offset_again;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index_dim;
} else if (Z_TYPE_P(offset) == IS_NULL) {
key = ZSTR_EMPTY_ALLOC();
@@ -42563,7 +42563,7 @@ fetch_dim_r_index_array:
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
offset = Z_LVAL_P(dim);
} else {
offset = zval_get_long(dim);
offset = zval_get_long_ex(dim, /* is_strict */ true);
}
ht = Z_ARRVAL_P(container);
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -42615,7 +42615,7 @@ fetch_dim_r_index_array:
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
offset = Z_LVAL_P(dim);
} else {
offset = zval_get_long(dim);
offset = zval_get_long_ex(dim, /* is_strict */ true);
}
ht = Z_ARRVAL_P(container);
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -45323,7 +45323,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -45412,7 +45412,7 @@ num_index_dim:
offset = Z_REFVAL_P(offset);
goto offset_again;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index_dim;
} else if (Z_TYPE_P(offset) == IS_NULL) {
key = ZSTR_EMPTY_ALLOC();
@@ -47063,7 +47063,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -50428,7 +50428,7 @@ num_index:
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index;
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -50517,7 +50517,7 @@ num_index_dim:
offset = Z_REFVAL_P(offset);
goto offset_again;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
hval = zend_dval_to_lval(Z_DVAL_P(offset));
hval = zend_dval_to_lval_safe(Z_DVAL_P(offset));
goto num_index_dim;
} else if (Z_TYPE_P(offset) == IS_NULL) {
key = ZSTR_EMPTY_ALLOC();
+3 -3
View File
@@ -9,14 +9,14 @@ if (PHP_INT_SIZE != 8) die("skip for 64bit platforms only");
--FILE--
<?php
var_dump(jdtounix(2465712));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440588));
var_dump(jdtounix((int)(PHP_INT_MAX / 86400 + 2440588)));
try {
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440589));
var_dump(jdtounix((int)(PHP_INT_MAX / 86400 + 2440589)));
} catch (ValueError $ex) {
echo $ex->getMessage(), PHP_EOL;
}
?>
--EXPECT--
--EXPECTF--
int(2170713600)
int(9223372036854720000)
jday must be between 2440588 and 106751993607888
+2 -2
View File
@@ -13,9 +13,9 @@ try {
} catch (ValueError $ex) {
echo $ex->getMessage(), PHP_EOL;
}
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440588));
var_dump(jdtounix((int)(PHP_INT_MAX / 86400 + 2440588)));
try {
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440589));
var_dump(jdtounix((int)(PHP_INT_MAX / 86400 + 2440589)));
} catch (ValueError $ex) {
echo $ex->getMessage(), PHP_EOL;
}
-101
View File
@@ -1,101 +0,0 @@
--TEST--
Test getdate() function : usage variation - Passing strings containing numbers
--FILE--
<?php
echo "*** Testing getdate() : usage variation ***\n";
date_default_timezone_set("Asia/Calcutta");
//Timezones with required data for date_sunrise
$inputs = array (
'String 0' => '0',
'String 10.5' => "10.5",
'String -10.5' => '-10.5',
);
// loop through each element of the array for timestamp
foreach($inputs as $key => $value) {
echo "\n--$key--\n";
var_dump( getdate($value) );
};
?>
--EXPECT--
*** Testing getdate() : usage variation ***
--String 0--
array(11) {
["seconds"]=>
int(0)
["minutes"]=>
int(30)
["hours"]=>
int(5)
["mday"]=>
int(1)
["wday"]=>
int(4)
["mon"]=>
int(1)
["year"]=>
int(1970)
["yday"]=>
int(0)
["weekday"]=>
string(8) "Thursday"
["month"]=>
string(7) "January"
[0]=>
int(0)
}
--String 10.5--
array(11) {
["seconds"]=>
int(10)
["minutes"]=>
int(30)
["hours"]=>
int(5)
["mday"]=>
int(1)
["wday"]=>
int(4)
["mon"]=>
int(1)
["year"]=>
int(1970)
["yday"]=>
int(0)
["weekday"]=>
string(8) "Thursday"
["month"]=>
string(7) "January"
[0]=>
int(10)
}
--String -10.5--
array(11) {
["seconds"]=>
int(50)
["minutes"]=>
int(29)
["hours"]=>
int(5)
["mday"]=>
int(1)
["wday"]=>
int(4)
["mon"]=>
int(1)
["year"]=>
int(1970)
["yday"]=>
int(0)
["weekday"]=>
string(8) "Thursday"
["month"]=>
string(7) "January"
[0]=>
int(-10)
}
-68
View File
@@ -1,68 +0,0 @@
--TEST--
Test gmmktime() function : usage variation - Passing positive and negative float values to arguments 32 bits.
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die('skip 32 bit only');
?>
--FILE--
<?php
echo "*** Testing gmmktime() : usage variation ***\n";
//Initialise variables
$hour = 8;
$min = 8;
$sec = 8;
$mon = 8;
$day = 8;
$year = 2008;
$inputs = array(
'float 123456' => 123456,
'float -123456' => -123456,
'float -10.5' => -10.5,
);
// loop through each element of the array for min
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) );
var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) );
var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) );
var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) );
var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) );
}
?>
--EXPECTF--
*** Testing gmmktime() : usage variation ***
--float 123456--
int(1662595688)
int(1225589768)
int(1218306336)
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
bool(false)
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
bool(false)
--float -123456--
int(773712488)
int(1210775048)
int(1218059424)
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
bool(false)
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
bool(false)
--float -10.5--
int(1218118088)
int(1218181808)
int(1218182870)
int(1170922088)
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
bool(false)
@@ -1,58 +0,0 @@
--TEST--
Test gmmktime() function : usage variation - Passing positive and negative float values to arguments 64 bits.
--SKIPIF--
<?php
if (PHP_INT_SIZE == 4) die('skip 64 bit only');
?>
--FILE--
<?php
echo "*** Testing gmmktime() : usage variation ***\n";
//Initialise variables
$hour = 8;
$min = 8;
$sec = 8;
$mon = 8;
$day = 8;
$year = 2008;
$inputs = array(
'float 123456' => 123456,
'float -123456' => -123456,
'float -10.5' => -10.5,
);
// loop through each element of the array for min
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) );
var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) );
var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) );
var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) );
var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) );
}
?>
--EXPECT--
*** Testing gmmktime() : usage variation ***
--float 123456--
int(1662595688)
int(1225589768)
int(1218306336)
int(325855037288)
int(3844412784488)
--float -123456--
int(773712488)
int(1210775048)
int(1218059424)
int(-323460834712)
int(-3968710530712)
--float -10.5--
int(1218118088)
int(1218181808)
int(1218182870)
int(1170922088)
int(-62465356312)
+1 -1
View File
@@ -38,7 +38,7 @@ $y = 0;
$cos_t = cos(deg2rad($delta_t));
$sin_t = sin(deg2rad($delta_t));
for ($angle = 0.0, $i = 0; $angle < 360.0; $angle += $delta_t, $i++) {
$bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF');
$bbox = imagettftext($g, 24, (int)$angle, (int)(400+$x), (int)(400+$y), $black, $font, 'ABCDEF');
imagepolygon($g, $bbox, $red);
printf("%2d: ", $i);
for ($j = 0; $j < 8; $j++) {
+2 -2
View File
@@ -78,8 +78,8 @@ foreach ($tests as $testnum => $test) {
// draw baseline:
$width = sqrt(pow($bboxDrawn[2] - $bboxDrawn[0], 2) + pow($bboxDrawn[3] - $bboxDrawn[1], 2));
imageline($g, $test['x'], $test['y'],
$test['x'] + $width * cos(deg2rad($test['angle'])),
$test['y'] - $width * sin(deg2rad($test['angle'])), $blue);
$test['x'] + (int)($width * cos(deg2rad($test['angle']))),
$test['y'] - (int)($width * sin(deg2rad($test['angle']))), $blue);
}
imagepng($g, "$cwd/bug53504.png");
+1 -1
View File
@@ -44,7 +44,7 @@ $SOURCE_IMG = $SAVE_DIR . "/test.png";
$im = imagecreatefrompng($SOURCE_IMG);
if (imagefilter($im, IMG_FILTER_COLORIZE, -127.12, -127.98, 127)) {
if (imagefilter($im, IMG_FILTER_COLORIZE, -127, -127, 127)) {
imagepng($im, $SAVE_DIR . "/IMG_FILTER_COLORIZE.png");
echo "IMG_FILTER_COLORIZE success\n";
unlink($SAVE_DIR . "/IMG_FILTER_COLORIZE.png");
+1 -1
View File
@@ -31,7 +31,7 @@ $points = array(
$x, $top,
$x+2*$d, $top,
$x+2*$d, $bot,
$x+$d, ($top+$bot)/2,
$x+$d, (int) (($top+$bot)/2),
$x, $bot
);
imagefilledpolygon($im, $points, $yellow);
-2
View File
@@ -23,7 +23,6 @@ try {
echo $e->getMessage() . \PHP_EOL;
}
var_dump(gmp_strval(gmp_fact(1.1)));
var_dump(gmp_strval(gmp_fact(20)));
var_dump(gmp_strval(gmp_fact("50")));
var_dump(gmp_strval(gmp_fact("10")));
@@ -52,7 +51,6 @@ gmp_fact(): Argument #1 ($num) is not an integer string
string(1) "1"
gmp_fact(): Argument #1 ($num) must be greater than or equal to 0
gmp_fact(): Argument #1 ($num) must be greater than or equal to 0
string(1) "1"
string(19) "2432902008176640000"
string(65) "30414093201713378043612608166064768844377641568960512000000000000"
string(7) "3628800"
-2
View File
@@ -9,7 +9,6 @@ var_dump(gmp_intval("-1"));
var_dump(gmp_intval(-1));
var_dump(gmp_intval(-2349828));
var_dump(gmp_intval(2342344));
var_dump(gmp_intval(1.0001));
$g = gmp_init("12345678");
var_dump(gmp_intval($g));
@@ -42,7 +41,6 @@ int(-1)
int(-1)
int(-2349828)
int(2342344)
int(1)
int(12345678)
gmp_intval(): Argument #1 ($num) is not an integer string
gmp_intval(): Argument #1 ($num) must be of type GMP|string|int, stdClass given
@@ -1,70 +0,0 @@
--TEST--
Test imap_fetch_overview() function : usage variations - FT_UID option
--SKIPIF--
<?php
require_once(__DIR__.'/setup/skipif.inc');
?>
--FILE--
<?php
/*
* Test passing a range of values into the $flags argument to imap_fetch_overview():
* 1. values that equate to 1
* 2. Minimum and maximum PHP values
*/
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
require_once __DIR__.'/setup/imap_include.inc';
// Initialise required variables
$stream_id = setup_test_mailbox('imapfetchoverviewvar3', 1); // set up temporary mailbox with one simple message
$msg_no = 1;
$msg_uid = imap_uid($stream_id, $msg_no);
$flags = [
'1',
true,
1.000000000000001,
0.00001e5,
245,
];
imap_check($stream_id);
foreach($flags as $option) {
echo "\nTesting with option value:";
var_dump($option);
try {
$overview = imap_fetch_overview($stream_id, $msg_uid, $option);
if ($overview) {
echo "imap_fetch_overview() returns an object\n";
}
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
}
?>
--CLEAN--
<?php
$mailbox_suffix = 'imapfetchoverviewvar3';
require_once(__DIR__.'/setup/clean.inc');
?>
--EXPECT--
*** Testing imap_fetch_overview() : usage variations ***
Create a temporary mailbox and add 1 msgs
New mailbox created
Testing with option value:string(1) "1"
imap_fetch_overview() returns an object
Testing with option value:bool(true)
imap_fetch_overview() returns an object
Testing with option value:float(1.000000000000001)
imap_fetch_overview() returns an object
Testing with option value:float(1)
imap_fetch_overview() returns an object
Testing with option value:int(245)
imap_fetch_overview(): Argument #3 ($flags) must be FT_UID or 0
@@ -1,74 +0,0 @@
--TEST--
Test imap_fetchbody() function : usage variations - FT_UID option
--SKIPIF--
<?php
require_once(__DIR__.'/setup/skipif.inc');
?>
--FILE--
<?php
/*
* Test if FT_UID is set by passing the following as $flags argument to imap_fetchbody():
* 1. values that equate to 1
* 2. Minimum and maximum PHP values
*/
echo "*** Testing imap_fetchbody() : usage variations ***\n";
require_once(__DIR__.'/setup/imap_include.inc');
// Initialise required variables
$stream_id = setup_test_mailbox('imapfetchbodyvar4', 1); // set up temporary mailbox with one simple message
$msg_no = 1;
$msg_uid = imap_uid($stream_id, $msg_no);
$section = 1;
//Note: the first four values are valid as they will all be cast to 1L.
$flags = array ('1', true,
1.000000000000001, 0.00001e5,
PHP_INT_MAX, -PHP_INT_MAX);
// iterate over each element of $flags array to test whether FT_UID is set
$iterator = 1;
imap_check($stream_id);
foreach($flags as $option) {
echo "\n-- Iteration $iterator --\n";
try {
if(is_string(imap_fetchbody($stream_id, $msg_uid, $section, $option))) {
echo "FT_UID valid\n";
} else {
echo "FT_UID not valid\n";
}
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
$iterator++;
}
?>
--CLEAN--
<?php
$mailbox_suffix = 'imapfetchbodyvar4';
require_once(__DIR__.'/setup/clean.inc');
?>
--EXPECT--
*** Testing imap_fetchbody() : usage variations ***
Create a temporary mailbox and add 1 msgs
New mailbox created
-- Iteration 1 --
FT_UID valid
-- Iteration 2 --
FT_UID valid
-- Iteration 3 --
FT_UID valid
-- Iteration 4 --
FT_UID valid
-- Iteration 5 --
imap_fetchbody(): Argument #4 ($flags) must be a bitmask of FT_UID, FT_PEEK, and FT_INTERNAL
-- Iteration 6 --
imap_fetchbody(): Argument #4 ($flags) must be a bitmask of FT_UID, FT_PEEK, and FT_INTERNAL
@@ -1,71 +0,0 @@
--TEST--
Test imap_fetchheader() function : usage variations - FT_UID option
--SKIPIF--
<?php
require_once(__DIR__.'/setup/skipif.inc');
?>
--FILE--
<?php
/*
* Test if FT_UID is set by passing the following as $flags argument to imap_fetchheader():
* 1. values that equate to 1
* 2. Minimum and maximum PHP values
*/
echo "*** Testing imap_fetchheader() : usage variations ***\n";
require_once(__DIR__.'/setup/imap_include.inc');
// Initialise required variables
$stream_id = setup_test_mailbox('imapfetchheadervar3', 1); // set up temporary mailbox with one simple message
$msg_no = 1;
$msg_uid = imap_uid($stream_id, $msg_no);
$flags = array ('1', true,
1.000000000000001, 0.00001e5,
PHP_INT_MAX, -PHP_INT_MAX);
// iterate over each element of $flags array to test whether FT_UID is set
$iterator = 1;
imap_check($stream_id);
foreach($flags as $option) {
echo "\n-- Iteration $iterator --\n";
try {
if (is_string(imap_fetchheader($stream_id, $msg_uid, $option))) {
echo "FT_UID valid\n";
} else {
echo "FT_UID not valid\n";
}
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
$iterator++;
}
?>
--CLEAN--
<?php
$mailbox_suffix = 'imapfetchheadervar3';
require_once(__DIR__ . '/setup/clean.inc');
?>
--EXPECT--
*** Testing imap_fetchheader() : usage variations ***
Create a temporary mailbox and add 1 msgs
New mailbox created
-- Iteration 1 --
FT_UID valid
-- Iteration 2 --
FT_UID valid
-- Iteration 3 --
FT_UID valid
-- Iteration 4 --
FT_UID valid
-- Iteration 5 --
imap_fetchheader(): Argument #3 ($flags) must be a bitmask of FT_UID, FT_PREFETCHTEXT, and FT_INTERNAL
-- Iteration 6 --
imap_fetchheader(): Argument #3 ($flags) must be a bitmask of FT_UID, FT_PREFETCHTEXT, and FT_INTERNAL
-2
View File
@@ -19,7 +19,6 @@ function ut_main()
-100,
-9999999999999,
9999999999999,
1.2,
);
$coll = ut_coll_create( 'en_US' );
@@ -48,4 +47,3 @@ Locale of type 100 is false
Locale of type -100 is false
Locale of type -9999999999999 is false
Locale of type 9999999999999 is false
Locale of type 1.2 is 'en_US'
@@ -54,7 +54,7 @@ foreach ([0x8790, 0x8791, 0x8792, 0x8795, 0x8796, 0x8797, 0x879A, 0x879B, 0x879C
$udcChars = array();
for ($cp = 0xE000; $cp < (0xE000 + (20 * 94)); $cp++) {
$i = $cp - 0xE000;
$bytes = ((($i / 94) + 0x7F - 0x5E) << 8) + (($i % 94) + 0x21);
$bytes = (( (int)($i / 94) + 0x7F - 0x5E) << 8) + (($i % 94) + 0x21);
$udcChars[pack('n', $bytes)] = pack('N', $cp);
}
@@ -106,7 +106,7 @@ foreach($inputs as $key =>$value) {
fclose($fp);
?>
--EXPECT--
--EXPECTF--
*** Testing mb_substitute_character(): various types in weak typing mode ***
--int 0--
bool(true)
@@ -117,14 +117,20 @@ bool(true)
--int -12345--
ValueError: mb_substitute_character(): Argument #1 ($substitute_character) is not a valid codepoint
--float 10.5--
Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d
bool(true)
--float -10.5--
Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d
ValueError: mb_substitute_character(): Argument #1 ($substitute_character) is not a valid codepoint
--float 10.0e19--
ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint
--float -10.0e19--
ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint
--float .5--
Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d
bool(true)
--empty array--
TypeError: mb_substitute_character(): Argument #1 ($substitute_character) must be of type string|int|null, array given
@@ -227,7 +227,7 @@ memory_limit=83886080
$current_targets = mt_rand(-100000, 100000) / 10;
do {
$trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL';
} while (isset($values[$trend]));
} while (isset($values[(string)$trend]));
$sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)',
$i,
@@ -239,7 +239,7 @@ memory_limit=83886080
break 2;
}
if ($current_targets > 0 && $trend !== 'NULL')
$values[$trend] = $i;
$values[(string)$trend] = $i;
}
krsort($values);
+8 -8
View File
@@ -399,7 +399,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim,
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
hval = zend_dval_to_lval_safe(Z_DVAL_P(dim));
goto num_index;
case IS_RESOURCE:
zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
@@ -464,7 +464,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
hval = zend_dval_to_lval_safe(Z_DVAL_P(dim));
goto num_index;
case IS_RESOURCE:
zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
@@ -527,7 +527,7 @@ static int ZEND_FASTCALL zend_jit_fetch_dim_isset_helper(zend_array *ht, zval *d
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
hval = zend_dval_to_lval_safe(Z_DVAL_P(dim));
goto num_index;
case IS_RESOURCE:
zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
@@ -594,7 +594,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
hval = zend_dval_to_lval_safe(Z_DVAL_P(dim));
goto num_index;
case IS_RESOURCE:
zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
@@ -667,7 +667,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
hval = zend_dval_to_lval_safe(Z_DVAL_P(dim));
goto num_index;
case IS_RESOURCE:
zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
@@ -736,7 +736,7 @@ try_again:
break;
}
return _zval_get_long_func(dim);
return zval_get_long_func(dim, /* is_strict */ false);
}
static zend_always_inline zend_string* zend_jit_fetch_dim_str_offset(zend_string *str, zend_long offset)
@@ -803,7 +803,7 @@ try_string_offset:
break;
}
offset = _zval_get_long_func(dim);
offset = zval_get_long_func(dim, /* is_strict */ false);
} else {
offset = Z_LVAL_P(dim);
}
@@ -1282,7 +1282,7 @@ isset_str_offset:
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, false))) {
lval = zval_get_long(offset);
lval = zval_get_long_ex(offset, /* is_strict */ true);
goto isset_str_offset;
}
}
+1 -1
View File
@@ -13896,7 +13896,7 @@ static int zend_jit_assign_obj_op(dasm_State **Dst,
IS_CV, opline->op1, var_addr, var_info, NULL,
(opline+1)->op1_type, (opline+1)->op1, val_addr, val_info,
val_range,
0, var_addr, var_def_info, var_info, 0)) {
0, var_addr, var_def_info, var_info, /* may throw */ 1)) {
return 0;
}
break;
+4
View File
@@ -1,5 +1,9 @@
--TEST--
Register Alloction 003: Reuse temporary register
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--INI--
opcache.enable=1
opcache.enable_cli=1
@@ -0,0 +1,28 @@
--TEST--
Register Alloction 003: Reuse temporary register
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.protect_memory=1
--EXTENSIONS--
opcache
--FILE--
<?php
function test($char_code) {
if ($char_code == !($char_code & 0xffffff80)) {
return "correct";
} else {
return "wrong";
}
}
echo test(65), "\n";
?>
--EXPECTF--
Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d
correct
+1 -1
View File
@@ -10,7 +10,7 @@ $password = "openssl";
$ivlen = openssl_cipher_iv_length($method);
$iv = '';
srand(time() + ((microtime(true) * 1000000) % 1000000));
srand(time() + ((int)(microtime(true) * 1000000) % 1000000));
while(strlen($iv) < $ivlen) $iv .= chr(rand(0,255));
$encrypted = openssl_encrypt($data, $method, $password, 0, $iv);
@@ -1,40 +0,0 @@
--TEST--
Test function posix_ttyname() by substituting argument 1 with float values.
--CREDITS--
Marco Fabbri mrfabbri@gmail.com
Francesco Fullone ff@ideato.it
#PHPTestFest Cesena Italia on 2009-06-20
--SKIPIF--
<?php
if (!extension_loaded('posix')) {
die('SKIP The posix extension is not loaded.');
}
?>
--FILE--
<?php
echo "*** Test substituting argument 1 with float values ***\n";
$variation_array = array(
'float 10.5' => 10.5,
'float -10.5' => -10.5,
'float 12.3456789000e10' => 12.3456789000e10,
'float -12.3456789000e10' => -12.3456789000e10,
'float .5' => .5,
);
foreach ( $variation_array as $var ) {
var_dump(posix_ttyname( $var ) );
}
?>
--EXPECT--
*** Test substituting argument 1 with float values ***
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
+1 -164
View File
@@ -9,23 +9,6 @@ ob_start();
echo "*** Testing session_encode() : error functionality ***\n";
// Get an unset variable
$unset_var = 10;
unset($unset_var);
class classA
{
public function __toString() {
return "Hello World!";
}
}
$heredoc = <<<EOT
Hello World!
EOT;
$fp = fopen(__FILE__, "r");
// Unexpected values to be passed as arguments
$inputs = array(
@@ -35,43 +18,11 @@ $inputs = array(
12345,
-2345,
// Float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// Null data
/*10*/ NULL,
null,
// Boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// Empty strings
/*16*/ "",
'',
// Invalid string data
/*18*/ "Nothing",
'Nothing',
$heredoc,
// Object data
/*21*/ new classA(),
// Undefined data
/*22*/ @$undefined_var,
// Unset data
/*23*/ @$unset_var,
// Resource variable
/*24*/ $fp
);
$iterator = 1;
@@ -88,7 +39,6 @@ foreach($inputs as $input) {
$iterator++;
};
fclose($fp);
echo "Done";
ob_end_flush();
?>
@@ -125,124 +75,11 @@ bool(true)
-- Iteration 5 --
bool(true)
Warning: session_encode(): Skipping numeric key 10 in %s on line %d
bool(false)
string(21) "|s:12:"Hello World!";"
bool(true)
-- Iteration 6 --
bool(true)
Warning: session_encode(): Skipping numeric key -10 in %s on line %d
bool(false)
bool(true)
-- Iteration 7 --
bool(true)
Warning: session_encode(): Skipping numeric key %s in %s on line %d
bool(false)
bool(true)
-- Iteration 8 --
bool(true)
Warning: session_encode(): Skipping numeric key 0 in %s on line %d
bool(false)
bool(true)
-- Iteration 9 --
bool(true)
Warning: session_encode(): Skipping numeric key 0 in %s on line %d
bool(false)
bool(true)
-- Iteration 10 --
bool(true)
string(21) "|s:12:"Hello World!";"
bool(true)
-- Iteration 11 --
bool(true)
string(21) "|s:12:"Hello World!";"
bool(true)
-- Iteration 12 --
bool(true)
Warning: session_encode(): Skipping numeric key 1 in %s on line %d
bool(false)
bool(true)
-- Iteration 13 --
bool(true)
Warning: session_encode(): Skipping numeric key 0 in %s on line %d
bool(false)
bool(true)
-- Iteration 14 --
bool(true)
Warning: session_encode(): Skipping numeric key 1 in %s on line %d
bool(false)
bool(true)
-- Iteration 15 --
bool(true)
Warning: session_encode(): Skipping numeric key 0 in %s on line %d
bool(false)
bool(true)
-- Iteration 16 --
bool(true)
string(21) "|s:12:"Hello World!";"
bool(true)
-- Iteration 17 --
bool(true)
string(21) "|s:12:"Hello World!";"
bool(true)
-- Iteration 18 --
bool(true)
string(28) "Nothing|s:12:"Hello World!";"
bool(true)
-- Iteration 19 --
bool(true)
string(28) "Nothing|s:12:"Hello World!";"
bool(true)
-- Iteration 20 --
bool(true)
string(33) "Hello World!|s:12:"Hello World!";"
bool(true)
-- Iteration 21 --
bool(true)
Illegal offset type
bool(false)
bool(true)
-- Iteration 22 --
bool(true)
string(21) "|s:12:"Hello World!";"
bool(true)
-- Iteration 23 --
bool(true)
string(21) "|s:12:"Hello World!";"
bool(true)
-- Iteration 24 --
bool(true)
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
Warning: session_encode(): Skipping numeric key %d in %s on line %d
bool(false)
bool(true)
Done
+4
View File
@@ -2,6 +2,10 @@
Bug #70211 (php 7 ZEND_HASH_IF_FULL_DO_RESIZE use after free)
--EXTENSIONS--
soap
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
<?php
+1 -1
View File
@@ -310,7 +310,7 @@ try_again:
break;
case IS_DOUBLE:
key->key = NULL;
key->h = (zend_long) Z_DVAL_P(offset);
key->h = zend_dval_to_lval_safe(Z_DVAL_P(offset));
break;
case IS_FALSE:
key->key = NULL;
+1 -1
View File
@@ -41,7 +41,7 @@ try_again:
}
break;
case IS_DOUBLE:
return zend_dval_to_lval(Z_DVAL_P(offset));
return zend_dval_to_lval_safe(Z_DVAL_P(offset));
case IS_LONG:
return Z_LVAL_P(offset);
case IS_FALSE:
@@ -1,14 +0,0 @@
--TEST--
SplFixedArray::__construct() with float passed as parameter.
--CREDITS--
PHPNW Test Fest 2009 - Jordan Hatch
--FILE--
<?php
$array = new SplFixedArray( 3.141 );
echo $array->getSize();
?>
--EXPECT--
3
@@ -1,8 +0,0 @@
--TEST--
SplFixedArray::offsetExists with various types
--CREDITS--
Gabriel Caruso (carusogabriel34@gmail.com)
--FILE--
<?php var_dump((new SplFixedArray(1))->offsetExists(0.1)); ?>
--EXPECT--
bool(false)
@@ -1,19 +0,0 @@
--TEST--
Using SplFixedArray::offsetGet() with various types
--CREDITS--
Gabriel Caruso (carusogabriel34@gmail.com)
--FILE--
<?php
$arr = new SplFixedArray(2);
$arr[0] = 'foo';
$arr[1] = 'bar';
var_dump($arr->offsetGet(0.2));
var_dump($arr->offsetGet(false));
var_dump($arr->offsetGet(true));
?>
--EXPECT--
string(3) "foo"
string(3) "foo"
string(3) "bar"
@@ -1,19 +0,0 @@
--TEST--
SplFixedArray::setSize() with a float param
--CREDITS--
PHPNW Testfest 2009 - Adrian Hardy
--FILE--
<?php
$fixed_array = new SplFixedArray(2);
$fixed_array->setSize(3.14159);
var_dump($fixed_array);
?>
--EXPECT--
object(SplFixedArray)#1 (3) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
}
@@ -19,5 +19,6 @@ try {
}
?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d
Illegal offset type
+1 -1
View File
@@ -6052,7 +6052,7 @@ PHP_FUNCTION(array_key_exists)
RETVAL_BOOL(zend_hash_exists(ht, ZSTR_EMPTY_ALLOC()));
break;
case IS_DOUBLE:
RETVAL_BOOL(zend_hash_index_exists(ht, zend_dval_to_lval(Z_DVAL_P(key))));
RETVAL_BOOL(zend_hash_index_exists(ht, zend_dval_to_lval_safe(Z_DVAL_P(key))));
break;
case IS_FALSE:
RETVAL_BOOL(zend_hash_index_exists(ht, 0));
@@ -226,6 +226,8 @@ array(3) {
["ccc"]=>
string(3) "333"
}
Deprecated: Implicit conversion from non-compatible float 0.123 to int in %s on line %d
array(3) {
["aaa"]=>
string(3) "111"
@@ -256,6 +258,8 @@ array(3) {
[2]=>
string(3) "ccc"
}
Deprecated: Implicit conversion from non-compatible float 3.14 to int in %s on line %d
array(0) {
}
@@ -52,7 +52,7 @@ $arrays = array (
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
$fp => 'resource', 133 => "int", 444.432 => "float",
$fp => 'resource', 133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
);
@@ -142,7 +142,7 @@ array(2) {
string(8) "resource"
}
-- Iteration 9 --
array(7) {
array(6) {
[1]=>
int(1)
["2.2"]=>
@@ -151,8 +151,6 @@ array(7) {
string(8) "resource"
["int"]=>
string(3) "int"
["float"]=>
string(5) "float"
["unset"]=>
string(5) "unset"
["heredoc"]=>
+31 -31
View File
@@ -2,7 +2,7 @@
basic array_fill test
--FILE--
<?php
$array1 = array(0.0, 1, 2.5);
$array1 = array(0.0, 1, 2);
$array2 = array(TRUE, FALSE, NULL, "d", "e", "f");
foreach($array1 as $start)
{
@@ -81,7 +81,7 @@ start: 0 num: 1 value: array(1) {
}
===========================
bool(true)
start: 0 num: 2.5 value: array(2) {
start: 0 num: 2 value: array(2) {
[0]=>
bool(true)
[1]=>
@@ -89,7 +89,7 @@ start: 0 num: 2.5 value: array(2) {
}
===========================
bool(false)
start: 0 num: 2.5 value: array(2) {
start: 0 num: 2 value: array(2) {
[0]=>
bool(false)
[1]=>
@@ -97,7 +97,7 @@ start: 0 num: 2.5 value: array(2) {
}
===========================
NULL
start: 0 num: 2.5 value: array(2) {
start: 0 num: 2 value: array(2) {
[0]=>
NULL
[1]=>
@@ -105,7 +105,7 @@ start: 0 num: 2.5 value: array(2) {
}
===========================
string(1) "d"
start: 0 num: 2.5 value: array(2) {
start: 0 num: 2 value: array(2) {
[0]=>
string(1) "d"
[1]=>
@@ -113,7 +113,7 @@ start: 0 num: 2.5 value: array(2) {
}
===========================
string(1) "e"
start: 0 num: 2.5 value: array(2) {
start: 0 num: 2 value: array(2) {
[0]=>
string(1) "e"
[1]=>
@@ -121,7 +121,7 @@ start: 0 num: 2.5 value: array(2) {
}
===========================
string(1) "f"
start: 0 num: 2.5 value: array(2) {
start: 0 num: 2 value: array(2) {
[0]=>
string(1) "f"
[1]=>
@@ -189,7 +189,7 @@ start: 1 num: 1 value: array(1) {
}
===========================
bool(true)
start: 1 num: 2.5 value: array(2) {
start: 1 num: 2 value: array(2) {
[1]=>
bool(true)
[2]=>
@@ -197,7 +197,7 @@ start: 1 num: 2.5 value: array(2) {
}
===========================
bool(false)
start: 1 num: 2.5 value: array(2) {
start: 1 num: 2 value: array(2) {
[1]=>
bool(false)
[2]=>
@@ -205,7 +205,7 @@ start: 1 num: 2.5 value: array(2) {
}
===========================
NULL
start: 1 num: 2.5 value: array(2) {
start: 1 num: 2 value: array(2) {
[1]=>
NULL
[2]=>
@@ -213,7 +213,7 @@ start: 1 num: 2.5 value: array(2) {
}
===========================
string(1) "d"
start: 1 num: 2.5 value: array(2) {
start: 1 num: 2 value: array(2) {
[1]=>
string(1) "d"
[2]=>
@@ -221,7 +221,7 @@ start: 1 num: 2.5 value: array(2) {
}
===========================
string(1) "e"
start: 1 num: 2.5 value: array(2) {
start: 1 num: 2 value: array(2) {
[1]=>
string(1) "e"
[2]=>
@@ -229,7 +229,7 @@ start: 1 num: 2.5 value: array(2) {
}
===========================
string(1) "f"
start: 1 num: 2.5 value: array(2) {
start: 1 num: 2 value: array(2) {
[1]=>
string(1) "f"
[2]=>
@@ -237,67 +237,67 @@ start: 1 num: 2.5 value: array(2) {
}
===========================
bool(true)
start: 2.5 num: 0 value: array(0) {
start: 2 num: 0 value: array(0) {
}
===========================
bool(false)
start: 2.5 num: 0 value: array(0) {
start: 2 num: 0 value: array(0) {
}
===========================
NULL
start: 2.5 num: 0 value: array(0) {
start: 2 num: 0 value: array(0) {
}
===========================
string(1) "d"
start: 2.5 num: 0 value: array(0) {
start: 2 num: 0 value: array(0) {
}
===========================
string(1) "e"
start: 2.5 num: 0 value: array(0) {
start: 2 num: 0 value: array(0) {
}
===========================
string(1) "f"
start: 2.5 num: 0 value: array(0) {
start: 2 num: 0 value: array(0) {
}
===========================
bool(true)
start: 2.5 num: 1 value: array(1) {
start: 2 num: 1 value: array(1) {
[2]=>
bool(true)
}
===========================
bool(false)
start: 2.5 num: 1 value: array(1) {
start: 2 num: 1 value: array(1) {
[2]=>
bool(false)
}
===========================
NULL
start: 2.5 num: 1 value: array(1) {
start: 2 num: 1 value: array(1) {
[2]=>
NULL
}
===========================
string(1) "d"
start: 2.5 num: 1 value: array(1) {
start: 2 num: 1 value: array(1) {
[2]=>
string(1) "d"
}
===========================
string(1) "e"
start: 2.5 num: 1 value: array(1) {
start: 2 num: 1 value: array(1) {
[2]=>
string(1) "e"
}
===========================
string(1) "f"
start: 2.5 num: 1 value: array(1) {
start: 2 num: 1 value: array(1) {
[2]=>
string(1) "f"
}
===========================
bool(true)
start: 2.5 num: 2.5 value: array(2) {
start: 2 num: 2 value: array(2) {
[2]=>
bool(true)
[3]=>
@@ -305,7 +305,7 @@ start: 2.5 num: 2.5 value: array(2) {
}
===========================
bool(false)
start: 2.5 num: 2.5 value: array(2) {
start: 2 num: 2 value: array(2) {
[2]=>
bool(false)
[3]=>
@@ -313,7 +313,7 @@ start: 2.5 num: 2.5 value: array(2) {
}
===========================
NULL
start: 2.5 num: 2.5 value: array(2) {
start: 2 num: 2 value: array(2) {
[2]=>
NULL
[3]=>
@@ -321,7 +321,7 @@ start: 2.5 num: 2.5 value: array(2) {
}
===========================
string(1) "d"
start: 2.5 num: 2.5 value: array(2) {
start: 2 num: 2 value: array(2) {
[2]=>
string(1) "d"
[3]=>
@@ -329,7 +329,7 @@ start: 2.5 num: 2.5 value: array(2) {
}
===========================
string(1) "e"
start: 2.5 num: 2.5 value: array(2) {
start: 2 num: 2 value: array(2) {
[2]=>
string(1) "e"
[3]=>
@@ -337,7 +337,7 @@ start: 2.5 num: 2.5 value: array(2) {
}
===========================
string(1) "f"
start: 2.5 num: 2.5 value: array(2) {
start: 2 num: 2 value: array(2) {
[2]=>
string(1) "f"
[3]=>
@@ -28,7 +28,6 @@ $input = array(
// numeric keys
1 => 'int_key', // expected: value will be replaced by 'bool_key3'
-2 => 'negative_key',
8.9 => 'float_key',
012 => 'octal_key',
0x34 => 'hex_key',
@@ -65,15 +64,13 @@ echo "Done"
?>
--EXPECTF--
*** Testing array_flip() : different keys for 'input' array argument ***
array(14) {
array(13) {
["bool_key4"]=>
int(0)
["bool_key3"]=>
int(1)
["negative_key"]=>
int(-2)
["float_key"]=>
int(8)
["octal_key"]=>
int(10)
["hex_key"]=>
@@ -42,11 +42,11 @@ $arrays = array (
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
133 => "int", 444.432 => "float",
133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
);
// array to be passsed to $arr2 argument
// array to be passed to $arr2 argument
$arr2 = array(0 => 0, 2 => "float", 4 => "f3", 33333333 => "f4",
"\tHello" => 111, 2.2, 'color', "Hello world" => "string",
"pen\n" => 33, 133 => "int");
@@ -42,11 +42,11 @@ $arrays = array (
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
133 => "int", 444.432 => "float",
133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
);
// array to be passsed to $arr1 argument
// array to be passed to $arr1 argument
$arr1 = array(0 => 0, 2 => "float", 4 => "f3", 33333333 => "f4",
"\tHello" => 111, 2.2, 'color', "Hello world" => "string",
"pen\n" => 33, 133 => "int");
@@ -42,11 +42,11 @@ $arrays = array (
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
133 => "int", 444.432 => "float",
133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
);
// array to be passsed to $arr2 argument
// array to be passed to $arr2 argument
$arr2 = array(1, "float", "f4", "hello", 2.2, 'color', "string", "pen\n", 11);
// loop through each sub-array within $arrays to check the behavior of array_intersect()
@@ -144,20 +144,16 @@ array(1) {
string(5) "hello"
}
-- Iterator 9 --
array(3) {
array(2) {
["hello"]=>
int(1)
["fruit"]=>
float(2.2)
[444]=>
string(5) "float"
}
array(3) {
array(2) {
["hello"]=>
int(1)
["fruit"]=>
float(2.2)
[444]=>
string(5) "float"
}
Done
@@ -42,11 +42,11 @@ $arrays = array (
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
133 => "int", 444.432 => "float",
133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
);
// array to be passsed to $arr1 argument
// array to be passed to $arr1 argument
$arr1 = array(1, "float", "f4", "hello", 2.2, 'color', "string", "pen\n", 11);
// loop through each sub-array within $arrays to check the behavior of array_intersect()
@@ -144,19 +144,15 @@ array(1) {
string(5) "hello"
}
-- Iterator 9 --
array(3) {
array(2) {
[0]=>
int(1)
[1]=>
string(5) "float"
[4]=>
float(2.2)
}
array(3) {
array(2) {
[0]=>
int(1)
[1]=>
string(5) "float"
[4]=>
float(2.2)
}
@@ -28,23 +28,29 @@ foreach($keys as $key) {
echo "Done";
?>
--EXPECT--
--EXPECTF--
*** Testing array_key_exists() : usage variations ***
-- Iteration 1 --
Pass float as $key:
Deprecated: Implicit conversion from non-compatible float 1.23456789E-10 to int in %s on line %d
bool(true)
Cast float to int:
bool(true)
-- Iteration 1 --
Pass float as $key:
Deprecated: Implicit conversion from non-compatible float 1.00000000000001 to int in %s on line %d
bool(true)
Cast float to int:
bool(true)
-- Iteration 1 --
Pass float as $key:
Deprecated: Implicit conversion from non-compatible float 1.99999999999999 to int in %s on line %d
bool(true)
Cast float to int:
bool(true)
@@ -1,24 +1,8 @@
--TEST--
Test array_keys() function (variation - 2)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php
echo "\n*** Testing array_keys() on range of values ***\n";
$arr_range = array(
2147483647 => 1,
2147483648 => 2,
-2147483647 => 3,
-2147483648 => 4,
-2147483649 => 5,
-0 => 6,
0 => 7
);
var_dump(array_keys($arr_range));
echo "\n*** Testing array_keys() on an array created on the fly ***\n";
var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3)));
var_dump(array_keys(array())); // null array
@@ -26,18 +10,6 @@ var_dump(array_keys(array())); // null array
echo "Done\n";
?>
--EXPECT--
*** Testing array_keys() on range of values ***
array(4) {
[0]=>
int(2147483647)
[1]=>
int(-2147483648)
[2]=>
int(-2147483647)
[3]=>
int(0)
}
*** Testing array_keys() on an array created on the fly ***
array(3) {
[0]=>
@@ -1,56 +0,0 @@
--TEST--
Test array_keys() function (variation - 2)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
<?php
echo "\n*** Testing array_keys() on range of values ***\n";
$arr_range = array(
2147483647 => 1,
2147483648 => 2,
-2147483647 => 3,
-2147483648 => 4,
-2147483649 => 5,
-0 => 6,
0 => 7
);
var_dump(array_keys($arr_range));
echo "\n*** Testing array_keys() on an array created on the fly ***\n";
var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3)));
var_dump(array_keys(array())); // null array
echo "Done\n";
?>
--EXPECT--
*** Testing array_keys() on range of values ***
array(6) {
[0]=>
int(2147483647)
[1]=>
int(2147483648)
[2]=>
int(-2147483647)
[3]=>
int(-2147483648)
[4]=>
int(-2147483649)
[5]=>
int(0)
}
*** Testing array_keys() on an array created on the fly ***
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
array(0) {
}
Done
@@ -53,7 +53,7 @@ $arrays = array (
// array with mixed values
/*11*/ array('hello' => 1, "fruit" => 2.2,
$fp => 'resource', 133 => "int", 444.432 => "float",
$fp => 'resource', 133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
);
@@ -135,7 +135,7 @@ array(2) {
string(8) "resource"
}
-- Iteration 9 --
array(7) {
array(6) {
["hello"]=>
int(1)
["fruit"]=>
@@ -144,8 +144,6 @@ array(7) {
string(8) "resource"
[133]=>
string(3) "int"
[444]=>
string(5) "float"
[""]=>
string(5) "unset"
["Hello world"]=>
@@ -48,7 +48,7 @@ $arrays = array (
array(@$unset_var => "hello", $fp => 'resource'),
// array with mixed values
/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc")
/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc")
);
// loop through the various elements of $arrays to test array_reverse()
@@ -273,16 +273,14 @@ array(2) {
}
-- Iteration 9 --
- default argument -
array(7) {
array(6) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[0]=>
string(5) "float"
[1]=>
string(3) "int"
[2]=>
[1]=>
string(8) "resource"
["fruit"]=>
float(2.2)
@@ -290,13 +288,11 @@ array(7) {
int(1)
}
- $preserve keys = true -
array(7) {
array(6) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[444]=>
string(5) "float"
[133]=>
string(3) "int"
[5]=>
@@ -307,16 +303,14 @@ array(7) {
int(1)
}
- $preserve_keys = false -
array(7) {
array(6) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[0]=>
string(5) "float"
[1]=>
string(3) "int"
[2]=>
[1]=>
string(8) "resource"
["fruit"]=>
float(2.2)
@@ -56,7 +56,7 @@ $arrays = array (
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
$fp => 'resource', 133 => "int", 444.432 => "float",
$fp => 'resource', 133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
);
@@ -288,8 +288,8 @@ array(5) {
string(8) "resource"
}
-- Iteration 9 --
int(8)
array(8) {
int(7)
array(7) {
[0]=>
int(10)
["hello"]=>
@@ -300,15 +300,13 @@ array(8) {
string(8) "resource"
[2]=>
string(3) "int"
[3]=>
string(5) "float"
[""]=>
string(5) "unset"
["Hello world"]=>
string(7) "heredoc"
}
int(10)
array(10) {
int(9)
array(9) {
[0]=>
int(10)
[1]=>
@@ -323,8 +321,6 @@ array(10) {
string(8) "resource"
[4]=>
string(3) "int"
[5]=>
string(5) "float"
[""]=>
string(5) "unset"
["Hello world"]=>
+2
View File
@@ -35,6 +35,8 @@ try {
?>
--EXPECTF--
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
Deprecated: Implicit conversion from non-compatible float 7.38 to int in %s on line %d
array(8) {
[10]=>
array(1) {
@@ -45,7 +45,6 @@ $array_arg = array(
// numeric keys
1 => 10, // expecting: value will be replaced by 'TRUE'
-2 => 9,
8.9 => 8,
012 => 7,
0x34 => 6,
@@ -86,7 +85,7 @@ echo "Done"
*** Testing uasort() : Sorting array with all possible keys ***
bool(true)
-- Sorted array after uasort() function call --
array(14) {
array(13) {
["multiline heredoc with 123
and speci@! ch@r..
check also"]=>
@@ -105,8 +104,6 @@ check also"]=>
int(25)
[-2]=>
int(9)
[8]=>
int(8)
[10]=>
int(7)
[52]=>
@@ -37,7 +37,7 @@ EOT3;
$array_arg = array(
// numeric keys
-2 => 9,
8.9 => 8,
8 => 8,
012 => 7,
0x34 => 6,
+3 -3
View File
@@ -68,7 +68,7 @@ function fill_buffer(&$buffer, $fill_type, $fill_size) {
return false;
}
$tmp_buff = str_repeat($data, ($fill_size/$size_divider) + $add_value );
$tmp_buff = str_repeat($data, (int)(($fill_size/$size_divider) + $add_value) );
if ( strlen($tmp_buff) > $fill_size ) {
$buffer = substr($tmp_buff, 0, $fill_size);
@@ -128,7 +128,7 @@ function fill_file($file_handle, $fill_type, $file_size) {
if ( $size <= $chunk_size ) {
$chunk_size = $size;
}
$num_values = str_repeat($data, ($chunk_size/$size_divider) + $add_value );
$num_values = str_repeat($data, (int) (($chunk_size/$size_divider) + $add_value) );
$bytes_written = fwrite($file_handle, $num_values, $chunk_size);
if ( $bytes_written != $chunk_size ) {
return false;
@@ -136,7 +136,7 @@ function fill_file($file_handle, $fill_type, $file_size) {
$size -= $chunk_size;
} while ( $size > 0 );
} else {
$num_values = str_repeat($data, ($chunk_size/$size_divider) + $add_value );
$num_values = str_repeat($data, (int) (($chunk_size/$size_divider) + $add_value) );
$bytes_written = fwrite($file_handle, $num_values, $file_size);
if ( $bytes_written != $file_size ) {
return false;
@@ -18,7 +18,6 @@ $operations = array(
LOCK_UN,
1,
2,
2.234,
TRUE
);
@@ -332,35 +331,5 @@ bool(true)
bool(true)
-- Inner iteration 13 in 8 --
bool(true)
--- Outer iteration 9 ---
bool(true)
-- Inner iteration 0 in 9 --
bool(true)
-- Inner iteration 1 in 9 --
bool(true)
-- Inner iteration 2 in 9 --
bool(true)
-- Inner iteration 3 in 9 --
bool(true)
-- Inner iteration 4 in 9 --
bool(true)
-- Inner iteration 5 in 9 --
bool(true)
-- Inner iteration 6 in 9 --
bool(true)
-- Inner iteration 7 in 9 --
bool(true)
-- Inner iteration 8 in 9 --
bool(true)
-- Inner iteration 9 in 9 --
bool(true)
-- Inner iteration 10 in 9 --
bool(true)
-- Inner iteration 11 in 9 --
bool(true)
-- Inner iteration 12 in 9 --
bool(true)
-- Inner iteration 13 in 9 --
bool(true)
*** Done ***
@@ -47,7 +47,7 @@ foreach($file_content_types as $file_content_type) {
echo "-- Testing ftruncate(): truncate file to half of its current size --\n";
/* truncate it to half of its current size */
$new_size = filesize($filename)/2;
$new_size = (int)(filesize($filename)/2);
var_dump( filesize($filename) ); // current filesize
var_dump( ftell($file_handle) );
var_dump( ftruncate($file_handle, $new_size) ); // truncate it
@@ -47,7 +47,7 @@ foreach($file_content_types as $file_content_type) {
echo "-- Testing ftruncate(): truncate file to half of its current size --\n";
/* truncate it to half of its current size */
$new_size = filesize($filename)/2;
$new_size = (int)(filesize($filename)/2);
var_dump( filesize($filename) ); // current filesize
var_dump( ftell($file_handle) );
var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+22 -1
View File
@@ -1,5 +1,9 @@
--TEST--
Bug #30695 (32 bit issues)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php
function toUTF8( $char_code )
@@ -8,6 +12,7 @@ Bug #30695 (32 bit issues)
{
case 0:
$char = chr( 0 );
break;
case !($char_code & 0xffffff80): // 7 bit
$char = chr( $char_code );
break;
@@ -32,6 +37,7 @@ Bug #30695 (32 bit issues)
chr(0x80 | (($char_code >> 12) & 0x3f)) .
chr(0x80 | (($char_code >> 6) & 0x3f)) .
chr(0x80 | ($char_code & 0x3f)) );
break;
default: // 31 bit
$char = ( chr(0xfc | (($char_code >> 30) & 0x01)) .
chr(0x80 | (($char_code >> 24) & 0x3f)) .
@@ -46,8 +52,23 @@ Bug #30695 (32 bit issues)
echo "\n", toUTF8(65), "\n", toUTF8(233), "\n", toUTF8(1252), "\n", toUTF8(20095), "\n";
?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d
A
Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d
Deprecated: Implicit conversion from non-compatible float 4294965248 to int in %s on line %d
é
Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d
Deprecated: Implicit conversion from non-compatible float 4294965248 to int in %s on line %d
Ӥ
Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d
Deprecated: Implicit conversion from non-compatible float 4294965248 to int in %s on line %d
Deprecated: Implicit conversion from non-compatible float 4294901760 to int in %s on line %d
乿
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff. Show more