XoopsModules25x/tag

View on GitHub
class/FormTag.php

Summary

Maintainability
A
35 mins
Test Coverage

__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');
Severity: Minor
Found in class/FormTag.php by phpmd

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');
Severity: Minor
Found in class/FormTag.php by phpmd

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)
Severity: Minor
Found in class/FormTag.php - About 35 mins to fix

    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 = '';
                }
    Severity: Minor
    Found in class/FormTag.php by phpmd

    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();
    Severity: Minor
    Found in class/FormTag.php by phpmd

    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();
    Severity: Minor
    Found in class/FormTag.php by phpmd

    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);
    Severity: Minor
    Found in class/FormTag.php by phpcodesniffer

    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>';
    Severity: Minor
    Found in class/FormTag.php by phpcodesniffer

    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(
    Severity: Minor
    Found in class/FormTag.php by phpcodesniffer

    Multi-line function call not indented correctly; expected 12 spaces but found 16
    Open

                    $delimiters
    Severity: Minor
    Found in class/FormTag.php by phpcodesniffer

    Multi-line function call not indented correctly; expected 12 spaces but found 16
    Open

                    '], [',
    Severity: Minor
    Found in class/FormTag.php by phpcodesniffer

    Multi-line function call not indented correctly; expected 8 spaces but found 12
    Open

                ) . ']';
    Severity: Minor
    Found in class/FormTag.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status