Skip to content

Coding standard "arguments on the same line" #16607

Closed
@leofeyer

Description

@leofeyer

I am referring to this:

* Declare all the arguments on the same line as the method/function name, no
matter how many arguments there are;

Now that we have constructor property promotion in PHP 8, do you still feel like this rule makes sense? Especially constructors can become quite long, e.g.:

class Request
{
    public function __construct(public array $query = [], public array $request = [], public array $attributes = [], public array $cookies = [], public array $files = [], public array $server = [], protected string|object|false|null $content = null)
    {
        $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
    }
}

Compared to:

class Request
{
    public function __construct(
        public array $query = [],
        public array $request = [],
        public array $attributes = [],
        public array $cookies = [],
        public array $files = [],
        public array $server = [],
        protected string|object|false|null $content = null
    ) {
        $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
    }
}

I realize that you are not promoting constructor property promotion yet (as explained in #16087) and I also realize that nobody has to adopt the Symfony coding style if they don‘t agree with it. However, removing that rule does not mean that anyone (including Symfony) has to change their code, so I figured we could at least discuss it.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)hasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions