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

Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present #3357

Closed
markstory opened this issue May 15, 2021 · 2 comments · Fixed by #3358
Milestone

Comments

@markstory
Copy link

Describe the bug
When a function has a return type and an additional new line between the brace and function signature, phpcbf will remove the return type.

Code sample

<?php

class FormattingBug
{
    public function extraLine(string: $a): void

    {
        // code here.
    }
}

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcbf --standard=PSR12 test.php

phpcbf will update the problematic formatting, however the resulting code looks like:

<?php

class FormattingBug
{
    public function extraLine(string: $a)
    {
        // code here.
    }
}

Expected behavior

Formatting to be updated without removing the return type.

@jrfnl
Copy link
Contributor

jrfnl commented May 15, 2021

@markstory Oh wow! Thanks for reporting this. Very curious to realize nobody has reported this before, even though return types have been used for years now.

Issue is reproducable and confirmed.

While when running with PSR12, the issue points to the Squiz.Functions.MultiLineFunctionDeclaration.BraceSpacing error code, the actual issue is in the Generic.Functions.FunctionOpeningBraceBsdAllman sniff.

PR #3358 should fix this. Testing appreciated.

@markstory
Copy link
Author

The output results look good to me! Thank you for the speedy fix ❤️

@gsherwood gsherwood added this to the 3.6.1 milestone May 23, 2021
@gsherwood gsherwood changed the title MultiLineFunctionDelclaration.BraceSpacing removes return type when additional lines are present. Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present May 27, 2021
gsherwood added a commit that referenced this issue May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants