From af5c3ad63bf20fac9280085a9c6873542b4f5085 Mon Sep 17 00:00:00 2001 From: LogMANOriginal Date: Mon, 5 Nov 2018 13:27:29 +0100 Subject: [PATCH] Updated Calling functions (markdown) --- Calling-functions.md => Functions.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) rename Calling-functions.md => Functions.md (72%) 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: