[wp-trac] [WordPress Trac] #52243: Rename `$this` when used in `@param` tags

WordPress Trac noreply at wordpress.org
Thu Jan 7 12:06:07 UTC 2021


#52243: Rename `$this` when used in `@param` tags
-------------------------+--------------------
 Reporter:  johnbillion  |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  5.7
Component:  Plugins      |    Version:
 Severity:  normal       |   Keywords:
  Focuses:  docs         |
-------------------------+--------------------
 Several filters and actions pass `$this` as a parameter. `$this` is a
 pseudo-variable that cannot be used as the name of a function parameter.

 I've identified a few problems caused by using `$this` as the name of a
 parameter for actions and filters:

 * Inexperienced developers may copy and paste the list of parameters from
 the `apply_filters()` call or from the developer.wordpress.org site when
 adding their filter and then experience a fatal error
 * Developer tools that consume filter and action docblocks, for example
 code generators, have to rename `$this` to avoid the same
 * PHPStan and other static analysis tools report `$this` as invalid when
 used in a `@param` tag

 Usage of `$this` in `@param` tags for actions and filters should be
 replaced with a more appropriate variable name.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52243>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list