kokororin / vscode-phpfmt

Integrates phpfmt into VS Code
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
BSD 3-Clause "New" or "Revised" License
130 stars 30 forks source link

Having space problem while using phpfmt [code formatter] with ...$variable_name #141

Closed Sourav1018 closed 6 months ago

Sourav1018 commented 6 months ago

Here is my example code where i am having error while using phpfmt [code formatter].

// actual code
function ( int | float...$numbers ): int | float {
    return array_sum( $numbers );
};

Here as we can see in the function parameter i am using Variable-length argument lists ... using this token, i am also declare the type of the variable. Now when i am trying to save it, phpfmt code formatter make the type and ... token together which i don't want, it is create confusion for other code readers.

I am using vscode as my code editor.

Here i am also provide my phpfmt vscode settings.

 "editor.formatOnSave": true,
 "phpfmt.passes": ["AlignDoubleArrow", "SpaceAroundParentheses"],
 "phpfmt.psr2": false,

I go through the phpfmt command list but i can't find any specific command for that.

// Expected code should be look like this
function ( int | float ...$numbers ): int | float {
    return array_sum( $numbers );
};
driade commented 6 months ago

Hi @Sourav1018 , this should be fixed in the latest release. May you please confirm?

Thanks.

Sourav1018 commented 6 months ago

@driade Hi currently i am using v1.1.37 current output is matched with expected.

$x = function ( int | float ...$numbers ): int | float {
    return array_sum( $numbers );
};

Thanks for resolve the issue.