1.2.412. 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; it may also throw an exception, trigger an error or simply die.
A method is considered empty when it contains nothing and it doesn’t overwrite a parent’s method. Constructors with promoted properties are considered non-empty.
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.412.1. Connex PHP features¶
1.2.412.1.1. Suggestions¶
Fill the function with actual code
Remove any usage of the function, then remove the function
1.2.412.1.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 |
Examples |
|
Available in |