Skip to content

[CodingStyle] Deprecate StaticClosureRector and StaticArrowFunctionRector#8092

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-depre-static
Jun 27, 2026
Merged

[CodingStyle] Deprecate StaticClosureRector and StaticArrowFunctionRector#8092
TomasVotruba merged 1 commit into
mainfrom
tv-depre-static

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Jun 27, 2026

Copy link
Copy Markdown
Member

What

Deprecate StaticClosureRector and StaticArrowFunctionRector.

Both rules add the static keyword to closures / arrow functions when they don't reference $this:

// before
$fn = function () { return 1; };
$arrow = fn (): string => 'test';

// after
$fn = static function () { return 1; };
$arrow = static fn (): string => 'test';

Why

  • Noisy, low value. The change touches almost every closure in a codebase, producing large diffs that bury the changes that actually matter during review.
  • No real-world benefit. Marking a closure static only prevents $this binding; it has no meaningful performance or correctness impact for typical code. It's a stylistic preference, not a fix.
  • Better left manual. Where a static closure is genuinely wanted, it's a one-line local decision - not something worth automating across a whole project

@TomasVotruba TomasVotruba merged commit 9ba9187 into main Jun 27, 2026
65 checks passed
@TomasVotruba TomasVotruba deleted the tv-depre-static branch June 27, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant