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

Code doesn't work after formatting #1959

Closed
mozesa opened this issue Mar 30, 2022 · 3 comments
Closed

Code doesn't work after formatting #1959

mozesa opened this issue Mar 30, 2022 · 3 comments
Labels

Comments

@mozesa
Copy link

mozesa commented Mar 30, 2022

Prettier 2.0.0

PHP Plugin 0.18.4

"prettier": {
  "phpVersion": "8.0",
  "useTabs": true,
  "singleQuote": true
}

Input:

$measurement  = (fn($m): Measurement => $m)(Measurement::query()->find($id, ['time', 'raw_gyro']));

image

Output:

$measurement = fn($m): Measurement => $m(
	Measurement::query()->find($id, ['time', 'raw_gyro']),
);

image

Expected behavior:
Won't broke the code.

@cseufert
Copy link
Collaborator

cseufert commented Jun 3, 2022

Yes, it appears the closure is being unwrapped at some point.

Simpler example

$a = (fn() => 0)(1);

becomes

$a = fn() => 0(1);

This could be a bug in the PHP parser that is used by us

@cseufert cseufert added the bug label Jun 3, 2022
@snake-py
Copy link

snake-py commented Sep 8, 2022

Seeing this bug as well

{
    "phpVersion": "8.1",
    "printWidth": 80,
    "tabWidth": 4,
    "useTabs": false,
    "singleQuote": false,
    "trailingCommaPHP": true,
    "braceStyle": "psr-2",
    "requirePragma": false,
    "insertPragma": false
}

@czosel
Copy link
Collaborator

czosel commented Sep 13, 2022

Released in 0.19.1 🎉

@czosel czosel closed this as completed Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants