method.default-last
Ensure that default paramters are sorted last in the paramters list
Examples
- Examples of correct code for this rule using default options
Default parameter is added last
php
<?php
function logInfo($message, $level = 1) {
echo $message;
}
function logError($message, $level = 5) {
echo $message;
}
function logWarning(){
echo $message;
}
function logMessage($message = 'Default'){
echo $message;
}
- Examples of incorrect code for this rule using default options
Default parameter is not added last
php
<?php
function logInfo($message, $level = 1, $source) {
echo $message;
}
function logError($level = 5, $message, $source) {
echo $message;
}
function logWarning($first_arg, $level = 5, $text = '', $second_arg, $third_arg) {
echo $message;
}