CRITICAL
Rule Definition
Goto statements make code harder to read and it is nearly impossible to understand the control flow of an application that uses this language construct. It should therefore be avoided.
Remediation
Modify the source code and consider replacing Goto statements with regular control structures and separate methods/functions, which are easier to read.
Violation Code Sample
class CastTest{
public function bar($param) {
A:
if ($param === 10) {
goto C;
}
B:
if (time() % 90 === 10) {
goto D;
}
C:
if (time() % 10 === 90) {
goto B;
}
D: return 90;
}
}
Reference
PHPMD - http://phpmd.org/rules/design.html#evalexpression
Related Technologies
Technical Criterion
Secure Coding - Input Validation
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.