- Methods must be named by following the naming conventions.
- Methods must always declare their visibility by using one of the private, protected, or public constructs.
- Like classes, the brace is always written right after the method name. There is no space between the function name and the opening parenthesis for the arguments.
- Functions in the global scope are strongly discouraged.
- This is an example of an acceptable function declaration in a class:
- Passing by-reference is permitted in the function declaration only:
- Call-time pass by-reference is prohibited.
- The return value must not be enclosed in parentheses. This can hinder readability and can also break code if a method is later changed to return by reference.
bar);
}
/**
* RIGHT
*/
public function bar() {
return \$this->bar;
}
}");
?>
- Function arguments are separated by a single trailing space after the comma delimiter. This is an example of an acceptable function call for a function that takes three arguments:
");
?>
- Call-time pass by-reference is prohibited. See the function declarations section for the proper way to pass function arguments by-reference.
- For functions whose arguments permitted arrays, the function call may include the "array" construct and can be split into multiple lines to improve readability. In these cases, the standards for writing arrays still apply:
");
?>