1.2.735. Multiple Functions Declarations¶
Some functions are declared multiple times in the code.
PHP accepts multiple definitions for the same functions, as long as they are not in the same file (linting error), or not included simultaneously during the execution.
This creates to several situations in which the same functions are defined multiple times : the function may be compatible with various PHP version, but their implementation may not. Or the function is part of a larger library, and sometimes only need without the rest of the library.
It is recommended to avoid having several functions with the same name in one repository. Turn those functions into methods and load them when needed.
<?php
namespace a {
function foo() {}
}
// Other file
namespace a {
function foo() {}
function bar() {}
}
?>
1.2.735.1. Connex PHP features¶
1.2.735.1.1. Specs¶
Short name |
Functions/MultipleDeclarations |
Rulesets |
|
Exakat since |
0.12.0 |
PHP Version |
All |
Severity |
|
Time To Fix |
|
Precision |
Very high |
Available in |