[wp-trac] [WordPress Trac] #14671: Deprecate the "accepted args" argument in add_filter() and add_action()
WordPress Trac
noreply at wordpress.org
Mon Jan 21 07:14:18 UTC 2013
#14671: Deprecate the "accepted args" argument in add_filter() and add_action()
-------------------------+-----------------------------
Reporter: markjaquith | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Plugins | Version:
Severity: normal | Resolution:
Keywords: has-patch |
-------------------------+-----------------------------
Comment (by rmccue):
Replying to [comment:25 westonruter]:
> I had the idea a couple years ago to use PHP's Reflection capabilities
to introspect the number of arguments defined on the function so that the
use of the `$accepted_args` 4th argument could be largely eliminated (as
5ubliminal also suggested above). At that time, WordPress still was
required to support PHP4, and so this was a dead end since Reflection was
introduced in PHP5. Now, however, since WordPress requires PHP≥5.2, it is
now safe to use Reflection and we can use it make our plugin code more
DRY.
I use [https://gist.github.com/5022591d312952d1245a#file-wp-
includes_class-wp-json-server-php-L389 parameter matching] using
Reflection in my own code and it's still reasonably fast. However, with
this specific issue, we should just be able to pass all the parameters in
(as if you set `$accepted_args` to `PHP_INT_MAX`) without issue, and use
`$accepted_args` as a fallback to limit it (I can't think of any good
reason not to, given that we have `current_filter`).
Also related, I have [https://github.com/rmccue/bbPress-Reply-by-
Email/blob/master/library/bbSubscriptions/Autohooker.php a class similar
to scribu's], but that uses PHPDoc tags. Again, this is still plenty fast
enough despite the heavy use of Reflection, so if we did want to go that
way, I'd argue the performance isn't really a consideration.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14671#comment:26>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list