Skip to content

Static closures should be employed whenever $this is not used #728

@westonruter

Description

@westonruter

Bug Description

There closures being used in the codebase which do not use $this. Granted, in most cases clases aren't even involved, but in those that are, using static is better for memory usage since the $this reference can be garbage collected. See SO answer.

I suggest that we do the following:

  1. Add static to all closures that don't use $this.
  2. Incorporate the SlevomatCodingStandard.Functions.StaticClosure sniff to catch this automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    InfrastructureIssues for the overall performance plugin infrastructure[Plugin] Performance LabIssue relates to work in the Performance Lab Plugin only[Type] BugAn existing feature is broken

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions