diff --git a/src/printer.mjs b/src/printer.mjs index 066b68f71..cec72d0f7 100644 --- a/src/printer.mjs +++ b/src/printer.mjs @@ -1410,7 +1410,7 @@ function printFunction(path, options, print) { const willBreakDeclaration = declaration.some(willBreak); if (willBreakDeclaration) { - return [printedDeclaration, " ", printedBody]; + return [...declAttrs, printedDeclaration, " ", printedBody]; } return [ diff --git a/tests/attributes/__snapshots__/jsfmt.spec.mjs.snap b/tests/attributes/__snapshots__/jsfmt.spec.mjs.snap index 16622e7c1..7d30d00a9 100644 --- a/tests/attributes/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/attributes/__snapshots__/jsfmt.spec.mjs.snap @@ -90,6 +90,28 @@ class Test } } + +class ParamCommentFunctionAnnotation { + + #[Foo] + function bar( + int $a, // parameter comment + int $b, + ) { + return $a + $b; + } + + #[Foo] + function bar2( + int $a, + int $middle, // parameter comment + int $b, + ) { + return $a + $middle + $b; + } + +} + =====================================output=====================================