[buddypress-trac] [BuddyPress Trac] #8611: Rename `$this` when used in `@param` tags

buddypress-trac noreply at wordpress.org
Sun Jan 2 21:18:52 UTC 2022


#8611: Rename `$this` when used in `@param` tags
-------------------------+-------------------------
 Reporter:  espellcaste  |      Owner:  espellcaste
     Type:  enhancement  |     Status:  assigned
 Priority:  low          |  Milestone:  Up Next
Component:  Core         |    Version:
 Severity:  trivial      |   Keywords:  needs-patch
-------------------------+-------------------------
 Inspired by https://core.trac.wordpress.org/ticket/52243 and confirmed we
 have many instances of the same. The description below is basically copied
 and pasted from that ticket.

 --

 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 https://developer.buddypress.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://buddypress.trac.wordpress.org/ticket/8611>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list