[wp-hackers] Can PHPdoc recognize custom filters?

Jeremy Clarke jer at simianuprising.com
Tue May 14 11:51:44 UTC 2013


On Mon, May 13, 2013 at 2:31 PM, Filippo Pisano <filippo.pisano at gmail.com>wrote:

> Is it possible to get PHPDoc to recognize WP filters declarations? I think
> that one thing like
>
> /**
>  * @filter_name my_filter
>  * @filter_param string $my_param
>  * @filter_args int 2
>  *
> **/
>

You can put something like that in your code if you want, but whatever tool
you're using to parse the PHPDoc won't do anything with it unless you add
support (i.e. with a NetBeans plugin or something like that).

One pattern I've seen in WP plugins is to set @uses add_action() as the
PHPDoc format for the line, then add details about the filter after.
Something like:

*@uses add_action() 'jer_after_thing_finishes' Runs after jer thing has
been loaded.*

or maybe:

*@uses add_action('jer_after_thing_finishes') Runs after jer thing has been
loaded.*

I'm not sure if the second one would be less 'valid' or not, but both have
the benefit of being very human readable as well as hopefully interacting
usefully with existing PHPDoc parsers.

-- 
Jeremy Clarke
Code and Design • globalvoicesonline.org


More information about the wp-hackers mailing list