__construct accesses the super-global variable $GLOBALS. Open
public function __construct($name, int $size, $maxlength, $value = '', $catid = 0)
{
$helper = \XoopsModules\Tag\Helper::getInstance();
require_once $helper->path('include/vars.php');
$helper->loadLanguage('main');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
__construct accesses the super-global variable $GLOBALS. Open
public function __construct($name, int $size, $maxlength, $value = '', $catid = 0)
{
$helper = \XoopsModules\Tag\Helper::getInstance();
require_once $helper->path('include/vars.php');
$helper->loadLanguage('main');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($name, int $size, $maxlength, $value = '', $catid = 0)
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = '';
}
- 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
Avoid using static access to class '\XoopsModules\Tag\Helper' in method '__construct'. Open
$helper = \XoopsModules\Tag\Helper::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'XoopsModules\Tag\Utility' in method 'render'. Open
$delimiters = Utility::tag_get_delimiter();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
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 28 and the first side effect is on line 23. Open
<?php declare(strict_types=1);
- Exclude checks
Line exceeds 120 characters; contains 177 characters Open
$delimiters[$key] = "<em style='font-weight: bold; color: #ff0000; font-style: normal;'>" . \htmlspecialchars($delimiters[$key], \ENT_QUOTES | \ENT_HTML5) . '</em>';
- Exclude checks
Line exceeds 120 characters; contains 289 characters Open
$render = "<input type='text' name='" . $this->getName() . "' id='" . $this->getName() . "' size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='" . $this->getValue() . "' " . $class . $this->getExtra() . '>' . \_MD_TAG_TAG_DELIMITER . ': [' . \implode(
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
$delimiters
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'], [',
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
) . ']';
- Exclude checks