[wp-trac] [WordPress Trac] #49032: Introduce __return_value()
WordPress Trac
noreply at wordpress.org
Wed Dec 18 18:40:32 UTC 2019
#49032: Introduce __return_value()
--------------------------------+-----------------------------
Reporter: giuseppe.mazzapica | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------------+-----------------------------
WordPress has, since quite long time, helper functions like
`__return_true` and
[[https://developer.wordpress.org/?s=__return_&post_type%5B%5D=wp-parser-
function|others]].
These are useful to be added to filters.
Now that minimum PHP version is 5.6 we could have something like:
{{{#!php
<?php
function __return_value($value) {
return static function () use ($value) {
return $value;
}
}
function __return_value_by_ref($value) {
return static function () use (&$value) {
return $value;
}
}
}}}
which would quite useful in many places, at least as useful as the other
mentioned functions that are already there.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49032>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list