plugin-php
plugin-php copied to clipboard
Code doesn't work after formatting
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']));
Output:
$measurement = fn($m): Measurement => $m(
Measurement::query()->find($id, ['time', 'raw_gyro']),
);
Expected behavior: Won't broke the code.
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
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
}
Released in 0.19.1
:tada: