WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 6 months ago

#45766 closed enhancement (fixed)

Doc: wp_list_sort() wrong DocBlock tag defination

Reported by: manikmist09 Owned by: desrosj
Milestone: 5.1 Priority: low
Severity: trivial Version: 4.7
Component: General Keywords: has-patch commit
Focuses: docs Cc:

Description

wp_list_sort() function is used in sorting a list of objects. This takes an array of objects as the first argument to sort. In the DocBlock its written as "An array of objects to filter." instead of "An array of objects to sort."

File Path wp-includes/functions.php

DocBlock should be

/**
 * Sorts a list of objects, based on one or more orderby arguments.
 *
 * @since 4.7.0
 *
 * @param array        $list          An array of objects to short.
 * @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.
 * @param bool         $preserve_keys Optional. Whether to preserve keys. Default false.
 * @return array The sorted array.
 */

Instead of

/**
 * Sorts a list of objects, based on one or more orderby arguments.
 *
 * @since 4.7.0
 *
 * @param array        $list          An array of objects to filter.
 * @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.
 * @param bool         $preserve_keys Optional. Whether to preserve keys. Default false.
 * @return array The sorted array.
 */

From

 * @param array        $list          An array of objects to filter.

To

 * @param array        $list          An array of objects to sort.

Attachments (1)

45766.diff (686 bytes) - added by manikmist09 6 months ago.

Download all attachments as: .zip

Change History (5)

@manikmist09
6 months ago

#1 follow-up: @mukesh27
6 months ago

  • Focuses docs added
  • Summary changed from wp_list_sort() wrong DocBlock tag defination to Doc: wp_list_sort() wrong DocBlock tag defination
  • Type changed from defect (bug) to enhancement
  • Version changed from 5.0.2 to 4.7

Hi @manikmist09, welcome to WordPress Trac! Thanks for the report.

Good cache. document added since 4.7

#2 in reply to: ↑ 1 @manikmist09
6 months ago

@mukesh27 thank you for updating this.
I had contributed to v4.9.3 last time.

#3 @swissspidy
6 months ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 5.1
  • Priority changed from normal to low
  • Severity changed from normal to trivial

#4 @desrosj
6 months ago

  • Owner set to desrosj
  • Resolution set to fixed
  • Status changed from new to closed

In 44480:

Docs: Improve accuracy of wp_list_sort()’s $list parameter description.

Props manikmist09.
Fixes #45766.

Note: See TracTickets for help on using tickets.