Skip to content

Instantly share code, notes, and snippets.

@MihailoJoksimovic
Created February 21, 2013 11:16
Show Gist options
  • Save MihailoJoksimovic/5004021 to your computer and use it in GitHub Desktop.
Save MihailoJoksimovic/5004021 to your computer and use it in GitHub Desktop.

4.4. Method Arguments

In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma.

Method arguments with default values MUST go at the end of the argument list.

<?php
namespace Vendor\Package;

class ClassName
{
    public function foo($arg1, &$arg2, $arg3 = [])
    {
        // method body
    }
}

Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line.

When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them.

<?php
namespace Vendor\Package;

class ClassName
{
    public function aVeryLongMethodName(
        ClassTypeHint $arg1,
        &$arg2,
        array $arg3 = []
    ) {
        // method body
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment