Make WordPress Core

Opened 10 months ago

Closed 10 months ago

Last modified 8 months ago

#59619 closed defect (bug) (fixed)

Remove discouraged `@return void` annotations

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 6.4 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: docs Cc:

Description

See https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#:~:text=Note%3A%20%40return%20void%20should%20not%20be%20used%20outside%20of%20the%20default%20bundled%20themes.

Note: @return void should not be used outside of the default bundled themes.

There were a few PHP instances of @return void added in 6.4, and other recent releases and thus violate that guideline.

Let's fix this throughout, except for themes (per the above), third-party libraries, and PHP compatibility code.

Also see relevant Gutenberg change for reference: https://github.com/WordPress/gutenberg/pull/55237

Change History (6)

This ticket was mentioned in PR #5484 on WordPress/wordpress-develop by @flixos90.


10 months ago
#1

  • Keywords has-patch added; needs-patch removed

@flixos90 commented on PR #5484:


10 months ago
#2

Should the docs be updated to say that @return void is also allowed in third-party libraries and PHP compatibility code?

Great idea @tellthemachines! I've opened a PR in https://github.com/WordPress/wpcs-docs/pull/133.

#3 @flixos90
10 months ago

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

In 56943:

General: Remove discouraged @return void annotations.

Such @return void annotations must not be used in WordPress core's PHP code, except bundled themes, third-party libraries, and PHP compatibility shims.

Props isabel_brison, swissspidy.
Fixes #59619.

#5 follow-up: @afercia
8 months ago

Just noticed that [56943] mentions three exceptions:

  • bundled themes
  • third-party libraries
  • PHP compatibility shims.

That makes sense, but the documentation linked in this issue only mentions bundled themes.

I guess it's worth considering updating the documentation page accordingly?

#6 in reply to: ↑ 5 @flixos90
8 months ago

Replying to afercia:

That makes sense, but the documentation linked in this issue only mentions bundled themes.

I guess it's worth considering updating the documentation page accordingly?

I have already attempted that, see https://github.com/WordPress/wpcs-docs/pull/133. Looks like that PR needs a third opinion?

Note: See TracTickets for help on using tickets.