Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#50020 closed defect (bug) (fixed)

WP_Theme get_post_templates incorrect @return docblock line?

Reported by: salvatoreformisano's profile salvatore.formisano Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: trivial Version:
Component: Themes Keywords: has-patch
Focuses: docs Cc:


As per title, the get_post_templates method of the WP_Theme class seems to have an incorrect @return docblock value. The @return type is set to string, but the method returns an array of the templates, and even the @return description literally says Array of page templates, keyed by filename and post type.

You can see this on line 1190 of class-wp-theme.php.

I noticed this because a plugin I am building calls this method and the IDE gave me a squiggly line when I worked with the method's output assuming it's an array.

Attachments (1)

50020.diff (497 bytes) - added by mayankmajeji 4 years ago.
Typo error corrected in class-wp-theme.php

Download all attachments as: .zip

Change History (4)

#1 @SergeyBiryukov
4 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to 5.5

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

Good catch, this appears to be a typo in [46661], which intended to switch the array to a more specific string[], but accidentally used string instead.

4 years ago

Typo error corrected in class-wp-theme.php

#2 @mayankmajeji
4 years ago

  • Keywords has-patch added; needs-patch good-first-bug removed

#3 @SergeyBiryukov
4 years ago

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

In 47631:

Docs: Correct @return type for WP_Theme::get_post_templates().

The method returns an array of strings, not a single string.

Props mayankmajeji, salvatore.formisano.
Fixes #50020.

Note: See TracTickets for help on using tickets.