Skip to content

Commit 09b9009

Browse files
committed
Make parameter $column_key optional in array_column()
1 parent 4a98b36 commit 09b9009

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

ext/standard/array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4666,10 +4666,10 @@ PHP_FUNCTION(array_column)
46664666
zend_long index_long = 0;
46674667
bool index_is_null = 1;
46684668

4669-
ZEND_PARSE_PARAMETERS_START(2, 3)
4669+
ZEND_PARSE_PARAMETERS_START(1, 3)
46704670
Z_PARAM_ARRAY_HT(input)
4671-
Z_PARAM_STR_OR_LONG_OR_NULL(column_str, column_long, column_is_null)
46724671
Z_PARAM_OPTIONAL
4672+
Z_PARAM_STR_OR_LONG_OR_NULL(column_str, column_long, column_is_null)
46734673
Z_PARAM_STR_OR_LONG_OR_NULL(index_str, index_long, index_is_null)
46744674
ZEND_PARSE_PARAMETERS_END();
46754675

ext/standard/basic_functions.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ function array_count_values(array $array): array {}
17371737
* @compile-time-eval
17381738
* @refcount 1
17391739
*/
1740-
function array_column(array $array, int|string|null $column_key, int|string|null $index_key = null): array {}
1740+
function array_column(array $array, int|string|null $column_key = null, int|string|null $index_key = null): array {}
17411741

17421742
/**
17431743
* @compile-time-eval

ext/standard/basic_functions_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
parameter $column_key of array_column() is optional
3+
--FILE--
4+
<?php
5+
6+
$array = [['a'], ['b']];
7+
var_dump(array_column($array, index_key: 0));
8+
9+
?>
10+
--EXPECT--
11+
array(2) {
12+
["a"]=>
13+
array(1) {
14+
[0]=>
15+
string(1) "a"
16+
}
17+
["b"]=>
18+
array(1) {
19+
[0]=>
20+
string(1) "b"
21+
}
22+
}

0 commit comments

Comments
 (0)