Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#56330 closed defect (bug) (fixed)

When does get_pages() return an array of ints?

Reported by: malthert's profile malthert Owned by: audrasjb's profile audrasjb
Milestone: 6.1 Priority: normal
Severity: trivial Version:
Component: Query Keywords: good-first-bug has-patch
Focuses: docs Cc:

Description

@return WP_Post[]|int[]|false

But afaik I always get WP_Post[]|false ? What do I need to do to get int[] ?

Attachments (2)

56330.patch (766 bytes) - added by jigar bhanushali 2 years ago.
correction of function return type
56330.2.patch (978 bytes) - added by jigar bhanushali 2 years ago.
Updated patch

Download all attachments as: .zip

Change History (11)

#1 @audrasjb
2 years ago

  • Milestone changed from Awaiting Review to 6.1

Indeed I can't see any way to retrieve an array of integers.

This return type mention was introduced in [49790] / #51800.

#2 @audrasjb
2 years ago

Pinging @johnbillion: any thought on this? :)

#3 @malthert
2 years ago

just to clarify: I don't actually want to get int[], I just think the @return is wrong and want it corrected.

#4 @johnbillion
2 years ago

  • Focuses docs added
  • Keywords needs-patch good-first-bug added

Confirmed, this should be WP_Post[]|false. Thanks for the report.

#5 @audrasjb
2 years ago

  • Owner set to audrasjb
  • Status changed from new to accepted

Great, thank for the confirmation! 👌

@jigar bhanushali
2 years ago

correction of function return type

#6 @jigar bhanushali
2 years ago

  • Keywords has-patch added; needs-patch removed

#7 @audrasjb
2 years ago

  • Keywords needs-refresh added

Thank you for the patch @jigar-bhanushali.

However, I have two small remarks:

  • We use the good-first-bug keyword as an invitation for new people who never contributed to WordPress Core before. It's better to keep it for new contributors.
  • Your patch doesn't meet WordPress Coding Standards as the indentation of the docblock needs to be updated accordingly :)

@jigar bhanushali
2 years ago

Updated patch

#8 @jigar bhanushali
2 years ago

  • Keywords needs-refresh removed

@audrasjb I have added an updated patch with correction.

#9 @audrasjb
2 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 53837:

Docs: Provide a more accurate @return type for get_pages() function.

Props malthert, audrasjb, johnbillion, jigar-bhanushali.
Fixes #56330.
See #55646.

Note: See TracTickets for help on using tickets.