Skip to content

$this should be allowed in closures #19

Closed
@sirbrillig

Description

@sirbrillig

The use of $this inside a closure should be fine, due to automatic binding. I'm not sure why there is an example explicitly marking this as a warning.

Here's a simple example that should report no warnings.

class classWithClosure() {
  public function test_get_source_information_from_theme() {
    doSomething( function() {
      return $this->thing;
    } );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions