1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/standard/tests/array/rcn_in_place.phpt
Niels Dossche 359a21f102 Fix RCN violations in array functions
When the array functions perform their operation in-place, the
`@refcount 1` annotation is wrong and causes a failure under
`ZEND_VERIFY_FUNC_INFO`.
The test file tests all functions that have the in-place optimization,
even those that didn't have the refcount annotation, just to prevent
future regressions.

Closes GH-18929.
2025-06-24 23:29:00 +02:00

58 lines
987 B
PHP

--TEST--
RCN check for in-place array modifications
--FILE--
<?php
// Important: do NOT replace range(0, 1) with a variable, these NEED to be TMPVARs!
var_dump(array_replace(range(0, 1), []));
var_dump(array_replace_recursive(range(0, 1), []));
var_dump(array_merge(range(0, 1), []));
var_dump(array_merge_recursive(range(0, 1), []));
var_dump(array_unique(range(0, 1)));
var_dump(array_intersect_ukey(range(0, 1), [], fn () => 0));
var_dump(array_intersect(range(0, 1), []));
var_dump(array_uintersect(range(0, 1), [], fn () => 0));
var_dump(array_intersect_uassoc(range(0, 1), [], fn () => 0));
var_dump(array_uintersect_uassoc(range(0, 1), [], fn () => 0, fn () => 0));
?>
--EXPECT--
array(2) {
[0]=>
int(0)
[1]=>
int(1)
}
array(2) {
[0]=>
int(0)
[1]=>
int(1)
}
array(2) {
[0]=>
int(0)
[1]=>
int(1)
}
array(2) {
[0]=>
int(0)
[1]=>
int(1)
}
array(2) {
[0]=>
int(0)
[1]=>
int(1)
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}