Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
westonruter opened this issue May 15, 2023 · 0 comments · Fixed by #729
Closed

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

westonruter opened this issue May 15, 2023 · 0 comments · Fixed by #729
Labels
Infrastructure Issues for the overall performance plugin infrastructure [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Bug An existing feature is broken
Milestone

Comments

@westonruter
Copy link
Member

westonruter commented May 15, 2023

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.
@westonruter westonruter added [Type] Bug An existing feature is broken Infrastructure Issues for the overall performance plugin infrastructure labels May 15, 2023
@westonruter westonruter added this to the 2.4.0 milestone May 15, 2023
@felixarntz felixarntz added the [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issues for the overall performance plugin infrastructure [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Bug An existing feature is broken
Projects
None yet
2 participants