Skip to content

Commit f77c04d

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix RCN violations in array functions
2 parents d2a30ac + 359a21f commit f77c04d

File tree

5 files changed

+59
-15
lines changed

5 files changed

+59
-15
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ PHP NEWS
3131

3232
- Standard:
3333
. Fix misleading errors in printf(). (nielsdos)
34+
. Fix RCN violations in array functions. (nielsdos)
3435

3536
- Streams:
3637
. Fixed GH-13264 (fgets() and stream_get_line() do not return false on filter

Zend/Optimizer/zend_func_infos.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,6 @@ static const func_info_t func_infos[] = {
393393
F1("compact", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
394394
FN("array_fill", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ANY),
395395
F1("array_fill_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
396-
F1("array_replace", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
397-
F1("array_replace_recursive", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
398396
FN("array_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
399397
FN("array_values", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
400398
F1("array_count_values", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG),
@@ -403,13 +401,8 @@ static const func_info_t func_infos[] = {
403401
F1("array_flip", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
404402
F1("array_change_key_case", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
405403
F1("array_intersect_key", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
406-
F1("array_intersect_ukey", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
407-
F1("array_intersect", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
408-
F1("array_uintersect", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
409404
F1("array_intersect_assoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
410405
F1("array_uintersect_assoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
411-
F1("array_intersect_uassoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
412-
F1("array_uintersect_uassoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
413406
F1("array_diff_key", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
414407
F1("array_diff_ukey", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
415408
F1("array_udiff", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),

ext/standard/basic_functions.stub.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,13 +1686,11 @@ function array_merge_recursive(array ...$arrays): array {}
16861686

16871687
/**
16881688
* @compile-time-eval
1689-
* @refcount 1
16901689
*/
16911690
function array_replace(array $array, array ...$replacements): array {}
16921691

16931692
/**
16941693
* @compile-time-eval
1695-
* @refcount 1
16961694
*/
16971695
function array_replace_recursive(array $array, array ...$replacements): array {}
16981696

@@ -1765,19 +1763,16 @@ function array_intersect_key(array $array, array ...$arrays): array {}
17651763

17661764
/**
17671765
* @param array|callable $rest
1768-
* @refcount 1
17691766
*/
17701767
function array_intersect_ukey(array $array, ...$rest): array {}
17711768

17721769
/**
17731770
* @compile-time-eval
1774-
* @refcount 1
17751771
*/
17761772
function array_intersect(array $array, array ...$arrays): array {}
17771773

17781774
/**
17791775
* @param array|callable $rest
1780-
* @refcount 1
17811776
*/
17821777
function array_uintersect(array $array, ...$rest): array {}
17831778

@@ -1795,13 +1790,11 @@ function array_uintersect_assoc(array $array, ...$rest): array {}
17951790

17961791
/**
17971792
* @param array|callable $rest
1798-
* @refcount 1
17991793
*/
18001794
function array_intersect_uassoc(array $array, ...$rest): array {}
18011795

18021796
/**
18031797
* @param array|callable $rest
1804-
* @refcount 1
18051798
*/
18061799
function array_uintersect_uassoc(array $array, ...$rest): array {}
18071800

ext/standard/basic_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
--TEST--
2+
RCN check for in-place array modifications
3+
--FILE--
4+
<?php
5+
// Important: do NOT replace range(0, 1) with a variable, these NEED to be TMPVARs!
6+
var_dump(array_replace(range(0, 1), []));
7+
var_dump(array_replace_recursive(range(0, 1), []));
8+
var_dump(array_merge(range(0, 1), []));
9+
var_dump(array_merge_recursive(range(0, 1), []));
10+
var_dump(array_unique(range(0, 1)));
11+
var_dump(array_intersect_ukey(range(0, 1), [], fn () => 0));
12+
var_dump(array_intersect(range(0, 1), []));
13+
var_dump(array_uintersect(range(0, 1), [], fn () => 0));
14+
var_dump(array_intersect_uassoc(range(0, 1), [], fn () => 0));
15+
var_dump(array_uintersect_uassoc(range(0, 1), [], fn () => 0, fn () => 0));
16+
?>
17+
--EXPECT--
18+
array(2) {
19+
[0]=>
20+
int(0)
21+
[1]=>
22+
int(1)
23+
}
24+
array(2) {
25+
[0]=>
26+
int(0)
27+
[1]=>
28+
int(1)
29+
}
30+
array(2) {
31+
[0]=>
32+
int(0)
33+
[1]=>
34+
int(1)
35+
}
36+
array(2) {
37+
[0]=>
38+
int(0)
39+
[1]=>
40+
int(1)
41+
}
42+
array(2) {
43+
[0]=>
44+
int(0)
45+
[1]=>
46+
int(1)
47+
}
48+
array(0) {
49+
}
50+
array(0) {
51+
}
52+
array(0) {
53+
}
54+
array(0) {
55+
}
56+
array(0) {
57+
}

0 commit comments

Comments
 (0)