1.2.409. Empty Function¶
Function or method whose body is empty.
Such functions or methods are rarely useful. As a bare minimum, the function should return some useful value, even if constant.
A method is considered empty when it contains nothing, or contains expressions without impact. Methods which overwrite another methods are omitted. Methods which are the concrete version of an abstract method are considered.
<?php
// classic empty function
function emptyFunction() {}
class bar {
// classic empty method
function emptyMethod() {}
// classic empty function
function emptyMethodWithParent() {}
}
class barbar extends bar {
// NOT an empty method : it overwrites the parent method
function emptyMethodWithParent() {}
}
?>
1.2.409.1. Suggestions¶
Fill the function with actual code
Remove any usage of the function, then remove the function
1.2.409.2. Specs¶
Short name |
Functions/EmptyFunction |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
function |
Examples |
|
Available in |