Skip to content

Commit 78e0b51

Browse files
committed
Code Quality: Preserve string[] input type in wp_parse_list() return.
This prevents unintentional widening of a `string[]` input to a `scalar[]` output, since strings are scalars. Follow-up to r62797. See #64898. git-svn-id: https://develop.svn.wordpress.org/trunk@62835 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5fd5a8e commit 78e0b51

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/wp-includes/functions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5034,9 +5034,13 @@ function wp_parse_args( $args, $defaults = array() ) {
50345034
* @since 5.1.0
50355035
*
50365036
* @param mixed[]|string $input_list List of values.
5037-
* @return array Array of values. A string is split into a list, while an array
5037+
* @return array Array of scalar values. A string is split into a list, while an array
50385038
* keeps its keys, so the result is not necessarily a list.
5039-
* @phpstan-return ( $input_list is string ? list<string> : array<scalar> )
5039+
* @phpstan-return (
5040+
* $input_list is string ? list<string> : (
5041+
* $input_list is array<string> ? array<string> : array<scalar>
5042+
* )
5043+
* )
50405044
*/
50415045
function wp_parse_list( $input_list ): array {
50425046
if ( ! is_array( $input_list ) ) {

0 commit comments

Comments
 (0)