Download this file
30 lines (23 with data), 629 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 | <?php
/**
* This file is an exemple of PHP file containing unoptimized code.
* This file should generate 2 warnings with the default config.
*/
class Optimisation {
/**
* Unoptimized function.
*
* @param String $a
* @param String $b
*/
function testOptimisation($a, $b) {
while ($a < count($b)) {
// 1 - functionInsideLoop : store count($b) in a temp variable :: PHPCHECKSTYLE_FUNCTION_INSIDE_LOOP
$a++;
}
for ($i = 0; $i < count($b); $i++) {
// 2- functionInsideLoop : store count($b) in a temp variable :: PHPCHECKSTYLE_FUNCTION_INSIDE_LOOP
echo $i;
}
}
}
|
×
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.