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

Opening brace on new line after return type when argument list is split across multiple lines #94

Open
Tracked by #97
rhertogh opened this issue Aug 13, 2024 · 0 comments

Comments

@rhertogh
Copy link

I'm not sure if this already has been discussed, if so, please let me know.

Currently the Method and Function Parameters section defines a function argument list split across multiple lines in combination with a return type as such:

class ReturnTypeVariations
{
    public function anotherFunction(
        string $foo,
        string $bar,
        int $baz,
    ): string {
        return 'foo';
    }
}

However, when the definition get bigger with for example default values and interfaces as return types, it becomes (IMO) less readable:

class ReturnTypeVariations
{
    public function anotherFunction(
        string $foo,
        string $bar,
        int $baz='default value',
    ): MyVeryLongCustomInterace {
        $myVar = 'inititial value';
    }
}

My proposal would be to place the opening brace on a new line when a function's argument list is split across multiple lines and a return type is specified:

class ReturnTypeVariations
{
    public function anotherFunction(
        string $foo,
        string $bar,
        int $baz='default value',
    ): MyVeryLongCustomInterace
    {
        $myVar = 'inititial value';
    }
}

Note that if no return type is specified, the opening brace must still be on the same line:

class ReturnTypeVariations
{
    public function anotherFunction(
        string $foo,
        string $bar,
        int $baz='default value',
    ) {
        $myVar = 'inititial value';
    }
}
@Crell Crell mentioned this issue Sep 3, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant