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

Fix bug in StaticClosure sniff #99

Merged
merged 1 commit into from
Nov 15, 2024
Merged

Fix bug in StaticClosure sniff #99

merged 1 commit into from
Nov 15, 2024

Conversation

tfrommen
Copy link
Member

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

This PR fixes a bug with a non-static fn arrow function using implicit return, fn () => 'foo', that could be static.

What is the current behavior? (You can also link to an open issue here)

Given this code:

fn () => 'foo'

phpcs will correctly report the closure being non-static, while it could. However, running phpcbf will result in the following invalid code:

static function () => 'foo'

Notice the implicit return that is invalid for a proper function.

What is the new behavior (if this is a feature change)?

With the PR merged, the fixed code will look like so:

static fn () => 'foo'

The closure is still an arrow function, making use of implicit return, but now static.

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No.

Other information:

@tfrommen tfrommen merged commit ea91b8d into version/2 Nov 15, 2024
32 checks passed
@tfrommen tfrommen deleted the fix-static-closure branch November 15, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants