diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/class-wp-list-util.php --- a/wp/wp-includes/class-wp-list-util.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/class-wp-list-util.php Fri Sep 05 18:40:08 2025 +0200 @@ -13,6 +13,7 @@ * * @since 4.7.0 */ +#[AllowDynamicProperties] class WP_List_Util { /** * The input array. @@ -116,12 +117,12 @@ if ( is_array( $obj ) ) { // Treat object as an array. if ( array_key_exists( $m_key, $obj ) && ( $m_value == $obj[ $m_key ] ) ) { - $matched++; + ++$matched; } } elseif ( is_object( $obj ) ) { // Treat object as an object. if ( isset( $obj->{$m_key} ) && ( $m_value == $obj->{$m_key} ) ) { - $matched++; + ++$matched; } } } @@ -165,8 +166,14 @@ foreach ( $this->output as $key => $value ) { if ( is_object( $value ) ) { $newlist[ $key ] = $value->$field; + } elseif ( is_array( $value ) ) { + $newlist[ $key ] = $value[ $field ]; } else { - $newlist[ $key ] = $value[ $field ]; + _doing_it_wrong( + __METHOD__, + __( 'Values for the input array must be either objects or arrays.' ), + '6.2.0' + ); } } @@ -186,12 +193,18 @@ } else { $newlist[] = $value->$field; } - } else { + } elseif ( is_array( $value ) ) { if ( isset( $value[ $index_key ] ) ) { $newlist[ $value[ $index_key ] ] = $value[ $field ]; } else { $newlist[] = $value[ $field ]; } + } else { + _doing_it_wrong( + __METHOD__, + __( 'Values for the input array must be either objects or arrays.' ), + '6.2.0' + ); } } @@ -206,9 +219,10 @@ * @since 4.7.0 * * @param string|array $orderby Optional. Either the field name to order by or an array - * of multiple orderby fields as $orderby => $order. - * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby - * is a string. + * of multiple orderby fields as `$orderby => $order`. + * Default empty array. + * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby` + * is a string. Default 'ASC'. * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. * @return array The sorted array. */