<li\>Methods must be named by following the naming conventions.
* Methods must be named by following the naming conventions.
</ul>
<ul>
<li\>Methods must always declare their visibility by using one of the private, protected, or public constructs.
* Methods must always declare their visibility by using one of the private, protected, or public constructs.
</ul>
<ul>
<li\>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.
* 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.
</ul>
<ul>
<li\>Functions in the global scope are strongly discouraged.
* Functions in the global scope are strongly discouraged.
</ul>
<ul>
<li\>This is an example of an acceptable function declaration in a class:
* This is an example of an acceptable function declaration in a class:
</ul>
<?php
<codetype="php">
renderCode("<?php
/**
/**
* Documentation Block Here
* Documentation Block Here
*/
*/
...
@@ -28,14 +27,11 @@ class Foo {
...
@@ -28,14 +27,11 @@ class Foo {
// entire content of function
// entire content of function
// must be indented four spaces
// must be indented four spaces
}
}
}");
}</code>
?>
* Passing by-reference is permitted in the function declaration only:
<ul>
<li\>Passing by-reference is permitted in the function declaration only:
<codetype="php">
</ul>
<?php
renderCode("<?php
/**
/**
* Documentation Block Here
* Documentation Block Here
*/
*/
...
@@ -46,16 +42,14 @@ class Foo {
...
@@ -46,16 +42,14 @@ class Foo {
public function bar(&\$baz) {
public function bar(&\$baz) {
}
}
}
}
");
</code>
?>
<ul>
* Call-time pass by-reference is prohibited.
<li\>Call-time pass by-reference is prohibited.
</ul>
<ul>
* 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.
<li\>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.
</ul>
<codetype="php">
<?php
renderCode("<?php
/**
/**
* Documentation Block Here
* Documentation Block Here
*/
*/
...
@@ -72,29 +66,24 @@ class Foo {
...
@@ -72,29 +66,24 @@ class Foo {
public function bar() {
public function bar() {
return \$this->bar;
return \$this->bar;
}
}
}");
}</code>
?>
<ul>
* 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:
<li\>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:
</ul>
<codetype="php">
<?php
renderCode("<?php
threeArguments(1, 2, 3);
threeArguments(1, 2, 3);
?>");
?></code>
?>
<ul>
* Call-time pass by-reference is prohibited. See the function declarations section for the proper way to pass function arguments by-reference.
<li\>Call-time pass by-reference is prohibited. See the function declarations section for the proper way to pass function arguments by-reference.
</ul>
<ul>
* 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:
<li\>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: