iconv_substr() can now be null. Null values will behave as if no length
argument was provided and will therefore return the remainder of the string
instead of an empty string.
+ . The length argument for array_splice() can now be null. Null values will
+ behave identically to omitting the argument, thus removing everything from
+ the 'offset' to the end of the array.
. The 'salt' option of password_hash() is no longer supported. If the 'salt'
option is used a warning is generated, the provided salt is ignored, and a
generated salt is used instead.
HashTable *rem_hash = NULL;
zend_long offset,
length = 0;
+ zend_bool length_is_null = 1;
int num_in; /* Number of elements in the input array */
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_ARRAY_EX(array, 0, 1)
Z_PARAM_LONG(offset)
Z_PARAM_OPTIONAL
- Z_PARAM_LONG(length)
+ Z_PARAM_LONG_OR_NULL(length, length_is_null)
Z_PARAM_ZVAL(repl_array)
ZEND_PARSE_PARAMETERS_END();
num_in = zend_hash_num_elements(Z_ARRVAL_P(array));
- if (ZEND_NUM_ARGS() < 3) {
+ if (length_is_null) {
length = num_in;
}
function array_unshift(array &$stack, ...$vars): int {}
-function array_splice(array &$arg, int $offset, int $length = UNKNOWN, $replacement = []): array {}
+function array_splice(array &$arg, int $offset, ?int $length = null, $replacement = []): array {}
function array_slice(array $arg, int $offset, ?int $length = null, bool $preserve_keys = false): array {}
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_splice, 0, 2, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(1, arg, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0)
- ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 1)
ZEND_ARG_INFO(0, replacement)
ZEND_END_ARG_INFO()
var_dump ($input);
// $input is now array("red", "green")
+echo "test truncation with null length \n";
+$input = array("red", "green", "blue", "yellow");
+var_dump (array_splice($input, 2, null));
+var_dump ($input);
+// $input is now array("red", "green")
+
echo "test removing entries from the middle \n";
$input = array("red", "green", "blue", "yellow");
var_dump (array_splice($input, 1, -1));
[1]=>
string(5) "green"
}
+test truncation with null length
+array(2) {
+ [0]=>
+ string(4) "blue"
+ [1]=>
+ string(6) "yellow"
+}
+array(2) {
+ [0]=>
+ string(3) "red"
+ [1]=>
+ string(5) "green"
+}
test removing entries from the middle
array(2) {
[0]=>