diff --git a/Calling-functions.md b/Functions.md similarity index 72% rename from Calling-functions.md rename to Functions.md index 7b40ded..c4952a8 100644 --- a/Calling-functions.md +++ b/Functions.md @@ -1,3 +1,25 @@ +# Parameters with default values must appear last in functions + +It is considered good practice to make parameters with default values last in function declarations. + +
Example

+ +**Bad** + +```PHP +function showTitle($duration = 60000, $title) { ... } +``` + +**Good** + +```PHP +function showTitle($title, $duration = 60000) { ... } +``` + +

+ +_Reference_: [`PEAR.Functions.ValidDefaultValue`](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php) + # Calling functions Function calls must follow a few rules in order to maintain readability throughout the project: