1.2.387. Duplicate Calls¶
Duplicate calls within the same context. They should be called once, and then cached in a variable for reuse.
This saves a lot of time of execution and reexecution of the same code. It is a micro-optimisation in case of a simple property fetch, but it may be more costly.
<?php
function foo($name) {
// The name decoration on the string is done twice. Once should be cached in a variable.
echo "Hello, ".ucfirst(strtolower($name))."<br />";
$query = 'Insert into visitors values ("'.ucfirst(strtolower($name)).'")';
$res = $db->query($query);
}
?>
See also Userland naming Guide.
1.2.387.1. Connex PHP features¶
1.2.387.1.1. Specs¶
Short name |
Structures/DuplicateCalls |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
ClearPHP |
|
Available in |