Skip to content

Commit 0250615

Browse files
committed
Added deprecated notice for cases where the behavior will change
1 parent 943c480 commit 0250615

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

Zend/zend_hash.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,14 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht,
789789
IS_CONSISTENT(ht);
790790
HT_ASSERT_RC1(ht);
791791

792+
/* Removing this block will end the deprecation phase and allow the new behavior */
793+
if (UNEXPECTED(flag & HASH_ADD_NEXT
794+
&& ht->nNextFreeElement > ZEND_LONG_MIN
795+
&& ht->nNextFreeElement < 0)) {
796+
zend_error(E_DEPRECATED, "In the next major version of PHP the implicit keys of this array will start from %d instead of 0", ht->nNextFreeElement);
797+
h = 0;
798+
}
799+
792800
if (h == ZEND_LONG_MIN && flag & HASH_ADD_NEXT) {
793801
h = 0;
794802
}

ext/standard/tests/array/array_fill_variation1.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ array(2) {
117117
int(100)
118118
}
119119
-- Iteration 2 --
120+
121+
Deprecated: In the next major version of PHP the implicit keys of this array will start from -9 instead of 0 in %s
120122
array(2) {
121123
[-10]=>
122124
int(100)
123-
[-9]=>
125+
[0]=>
124126
int(100)
125127
}
126128
-- Iteration 3 --

ext/standard/tests/array/array_fill_variation1_64bit.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ array(2) {
117117
int(100)
118118
}
119119
-- Iteration 2 --
120+
121+
Deprecated: In the next major version of PHP the implicit keys of this array will start from -9 instead of 0 in %s
120122
array(2) {
121123
[-10]=>
122124
int(100)
123-
[-9]=>
125+
[0]=>
124126
int(100)
125127
}
126128
-- Iteration 3 --

ext/standard/tests/array/bug67693.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ var_dump($array);
1414

1515
echo"\nDone";
1616
?>
17-
--EXPECT--
17+
--EXPECTF--
18+
Deprecated: In the next major version of PHP the implicit keys of this array will start from -1 instead of 0 in %s
1819
array(2) {
19-
[-1]=>
20-
int(0)
2120
[0]=>
2221
int(0)
22+
[1]=>
23+
int(0)
2324
}
2425

2526
Done

ext/standard/tests/array/count_recursive.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ fclose( $resource1 );
130130
closedir( $resource2 );
131131
?>
132132
--EXPECTF--
133+
Deprecated: In the next major version of PHP the implicit keys of this array will start from -1 instead of 0 in %s
133134
*** Testing basic functionality of count() function ***
134135
-- Testing NULL --
135136

0 commit comments

Comments
 (0)