Fix a zend compat issue in array_slice
- Fix the behavior of array_slice when using PHP_INT_MAX
Esse commit está contido em:
@@ -94,7 +94,7 @@ Variant ArrayUtil::Chunk(CArrRef input, int size,
|
||||
return ret;
|
||||
}
|
||||
|
||||
Variant ArrayUtil::Slice(CArrRef input, int offset, int length,
|
||||
Variant ArrayUtil::Slice(CArrRef input, int offset, int64_t length,
|
||||
bool preserve_keys) {
|
||||
int num_in = input.size();
|
||||
if (offset > num_in) {
|
||||
@@ -126,7 +126,7 @@ Variant ArrayUtil::Slice(CArrRef input, int offset, int length,
|
||||
return out_hash;
|
||||
}
|
||||
|
||||
Variant ArrayUtil::Splice(CArrRef input, int offset, int length /* = 0 */,
|
||||
Variant ArrayUtil::Splice(CArrRef input, int offset, int64_t length /* = 0 */,
|
||||
CVarRef replacement /* = null_variant */,
|
||||
Array *removed /* = NULL */) {
|
||||
int num_in = input.size();
|
||||
|
||||
@@ -59,14 +59,14 @@ public:
|
||||
* into numerically keyed map. When "preserve_keys" is false, a map will
|
||||
* turn into vectors, unless keys are not numeric.
|
||||
*/
|
||||
static Variant Slice(CArrRef input, int offset, int length,
|
||||
static Variant Slice(CArrRef input, int offset, int64_t length,
|
||||
bool preserve_keys);
|
||||
|
||||
/**
|
||||
* Removes the elements designated by offset and length and replace them
|
||||
* with supplied array.
|
||||
*/
|
||||
static Variant Splice(CArrRef input, int offset, int length = 0,
|
||||
static Variant Splice(CArrRef input, int offset, int64_t length = 0,
|
||||
CVarRef replacement = null_variant,
|
||||
Array *removed = nullptr);
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
|
||||
/**
|
||||
* Returns input as a numerically indexed array starting from zero
|
||||
* with no gaps. Is optimized for the case where input is already
|
||||
* with no gaps. Is optimized for the case where input is already
|
||||
* correct. Assumes input is not null.
|
||||
*/
|
||||
static Array EnsureIntKeys(CArrRef input);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$a = array(1, 2, 3);
|
||||
var_dump(array_slice($a, 0, PHP_INT_MAX));
|
||||
@@ -0,0 +1,8 @@
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$a = array(1, 2, 3);
|
||||
var_dump(array_splice($a, 0, PHP_INT_MAX));
|
||||
@@ -0,0 +1,8 @@
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Prototype : array array_slice(array $input, int $offset [, int $length [, bool $preserve_keys]])
|
||||
* Description: Returns elements specified by offset and length
|
||||
* Description: Returns elements specified by offset and length
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
@@ -48,7 +48,7 @@ $inputs = array(
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
|
||||
// empty data
|
||||
/*16*/ "",
|
||||
'',
|
||||
Referência em uma Nova Issue
Bloquear um usuário