WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#37830 closed enhancement (wontfix)

WP_Query can collapse several methods using __call()

Reported by: wonderboymusic Owned by: wonderboymusic
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords: revert
Focuses: docs Cc:

Description

There are a variety of is_* methods that also exist as properties. The functions simply cast to bool. These can all be collapsed using __call() and @method annotations.

Patch attached.

Attachments (1)

37830.diff (4.9 KB) - added by wonderboymusic 3 years ago.

Download all attachments as: .zip

Change History (7)

@wonderboymusic
3 years ago

#1 @wonderboymusic
3 years ago

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

In 38356:

Query: collapse several of the is_* methods using __call(). Add @method annotations.

Fixes #37830.

#2 @ocean90
3 years ago

  • Focuses docs added
  • Keywords 2nd-opinion added
  • Resolution fixed deleted
  • Status changed from closed to reopened

May I ask which problem [38356] solves? I'm not really a fan of magic methods because they are … magic. How does this impact performance?

Through the @method annotation we seem to lose the @since tag. @DrewAPicture does DevHub support @method annotations or would we lose the methods/docs of these methods without further adjustments?

#3 @DrewAPicture
3 years ago

  • Keywords revert added

@ocean90 is correct that we lose data on when these methods were introduced. And I think more importantly we lose a lot of context that is useful to developers unfamiliar with the is_*() methods.

DevHub doesn't currently support @method tags, that is to say, the parser of course understands the tags but we don't expose the data in any form on DevHub. I think the preference here would be to keep the methods as non-magic to retain the extra context and versioning information.

#4 @johnbillion
3 years ago

  • Keywords has-patch 2nd-opinion removed

#5 @wonderboymusic
3 years ago

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

In 38471:

Query: r38356, you were not long for this world.

Fixes #37830.

#6 @ocean90
3 years ago

  • Milestone 4.7 deleted
  • Resolution changed from fixed to wontfix
Note: See TracTickets for help on using tickets.