Access Modifiers & Function Calls
In this lesson we will look at the styling rules for using access modifiers and making function calls.
abstract, final, and static
When present, the abstract
and final
declarations MUST precede the visibility declaration.
When present, the static
declaration MUST come after the visibility declaration.
<?phpnamespace Vendor\Package;abstract class ClassName{protected static $foo;abstract protected function zim();final public static function bar(){// method body}}
Method and Function Calls
When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis, there MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma.
<?phpbar();$foo->bar($arg1);Foo::bar($arg2, $arg3);
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.
<?php$foo->bar($longArgument,$longerArgument,$muchLongerArgument);