Opened 20 months ago

Closed 17 months ago

Last modified 17 months ago

#18845 closed enhancement (fixed)

Introduce __return_null()

Reported by: johnbillion Owned by: nacin
Priority: normal Milestone: 3.4
Component: General Version: 3.3
Severity: normal Keywords: has-patch commit 3.4-early
Cc:

Description

I've recently had some uses for __return_null().

Attachments (1)

18845.patch (592 bytes) - added by johnbillion 20 months ago.

Download all attachments as: .zip

Change History (9)

  • Keywords has-patch added

comment:2 follow-up: ↓ 3   scribu20 months ago

  • Keywords reporter-feedback added

Could you list those uses by any chance?

comment:3 in reply to: ↑ 2   johnbillion20 months ago

  • Keywords reporter-feedback removed

Replying to scribu:

Could you list those uses by any chance?

Sure. The transient API and the options API let you short-circuit values using the pre_transient_{transient} and pre_option_{option} filters. __return_null() allows a null short circuit value. __return_false() can't be used because the short circuits use === to check for false.

  • Keywords commit 3.4-early added
  • Milestone changed from Awaiting Review to Future Release

I doubt there's much of a use case for returning null but it's nice to have the consistent function.

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

In [19607]:

Add __return_null() to complement the existing true, false, zero, and empty array methods. props johnbillion, fixes #18845.

In [19608]:

Update since. see #18845.

  • Milestone changed from Future Release to 3.4
Note: See TracTickets for help on using tickets.