class/form/simpleform.php
The method render uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$ret .= $ele->render() . "\n";
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class UserlogSimpleForm extends XoopsForm
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 30 and the first side effect is on line 20. Open
Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 186 characters Open
Open
$ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n";
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
Open
$ret .= '<div class="' . $ele->getClass() . '"><strong>' . $ele->getCaption() . '</strong>' . $ele->render() . '</div>';
- Exclude checks