Skip to content

Commit bb74a56

Browse files
PHPMD files
1 parent ef04b8d commit bb74a56

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

bad.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
class BadDesign
4+
{
5+
// No class doc comment — cleancode
6+
7+
public function messyFunction($a, $b)
8+
{
9+
// No function doc comment — cleancode
10+
11+
$unused = 123; // unused variable — cleancode
12+
13+
// Long method with nested loops — codesize + design
14+
$sum = 0;
15+
for ($i = 0; $i < 10; $i++) {
16+
for ($j = 0; $j < 10; $j++) {
17+
$sum += $i * $j;
18+
}
19+
}
20+
21+
// Excessive method complexity — design
22+
if ($a > 10) {
23+
if ($b < 5) {
24+
for ($k = 0; $k < 5; $k++) {
25+
$sum += $k;
26+
}
27+
} else {
28+
while ($b > 0) {
29+
$sum -= $b;
30+
$b--;
31+
}
32+
}
33+
}
34+
35+
return $sum;
36+
}
37+
}
38+
39+
$obj = new BadDesign();
40+
echo $obj->messyFunction(15, 3);

0 commit comments

Comments
 (0)