ImpressCMS/impresscms

View on GitHub
htdocs/modules/system/admin/userrank/class/userrank.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '128', column '23').
Open

            $criteria->add(new icms_db_criteria_Item("rank_special", "0"));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '126', column '23').
Open

            $criteria->add(new icms_db_criteria_Item("rank_min", $posts, "<="));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '124', column '23').
Open

            $criteria->add(new icms_db_criteria_Item("rank_id", $rank_id));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '122', column '19').
Open

        $criteria = new icms_db_criteria_Compo();

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '127', column '23').
Open

            $criteria->add(new icms_db_criteria_Item("rank_max", $posts, ">="));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method getRank uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $rank = array(
                "id" => $rank_id,
                "title" => $ranks[0]->getVar("rank_title"),
                "image" => $this->getImageUrl() . $ranks[0]->getVar("rank_image"));

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 'icms_core_Filesystem' in method 'MoveAllRanksImagesToProperPath'.
Open

                icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value);

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

The method getRank uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $criteria->add(new icms_db_criteria_Item("rank_min", $posts, "<="));
            $criteria->add(new icms_db_criteria_Item("rank_max", $posts, ">="));
            $criteria->add(new icms_db_criteria_Item("rank_special", "0"));
        }

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 count() function in for loops.
Open

        for ($i = 0; $i < count($Query); $i++) {
            $values[] = $Query[$i]["rank_image"];
        }

CountInLoopExpression

Since: 2.7.0

Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

Example

class Foo {

  public function bar()
  {
    $array = array();

    for ($i = 0; count($array); $i++) {
      // ...
    }
  }
}

Source https://phpmd.org/rules/design.html#countinloopexpression

Reference to undeclared constant \XOBJ_DTYPE_TXTBOX
Open

        $this->quickInitVar("rank_title", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_TITLE, _CO_ICMS_USERRANK_RANK_TITLE_DSC);

Reference to undeclared class \icms_ipf_Object
Open

        return parent::getVar($key, $format);

Reference to undeclared constant \XOBJ_DTYPE_INT
Open

        $this->quickInitVar("rank_special", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_SPECIAL, _CO_ICMS_USERRANK_RANK_SPECIAL_DSC);

Call to method __construct from undeclared class \icms_db_criteria_Item
Open

            $criteria->add(new icms_db_criteria_Item("rank_min", $posts, "<="));

Call to undeclared method \SystemUserrankHandler::getImageUrl
Open

                "image" => $this->getImageUrl() . $ranks[0]->getVar("rank_image"));

Call to undeclared method \SystemUserrank::setControl
Open

        $this->setControl("rank_special", "yesno");

Reference to undeclared property \SystemUserrank->handler
Open

        $ret = '<img src="' . $this->handler->getImageUrl() . $this->getVar("rank_image") . '" />';

Call to method copyRecursive from undeclared class \icms_core_Filesystem
Open

                icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value);

Reference to undeclared constant \XOBJ_DTYPE_INT
Open

        $this->quickInitVar("rank_id", XOBJ_DTYPE_INT, TRUE);

Call to undeclared method \SystemUserrank::quickInitVar
Open

        $this->quickInitVar("rank_id", XOBJ_DTYPE_INT, TRUE);

Reference to undeclared constant \XOBJ_DTYPE_INT
Open

        $this->quickInitVar("rank_min", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MIN, _CO_ICMS_USERRANK_RANK_MIN_DSC);

Reference to undeclared constant \XOBJ_DTYPE_TXTBOX
Open

        $this->quickInitVar("rank_image", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_IMAGE, _CO_ICMS_USERRANK_RANK_IMAGE_DSC);

Call to method __construct from undeclared class \icms_db_criteria_Compo
Open

        $criteria = new icms_db_criteria_Compo();

Reference to undeclared class \icms_ipf_Object
Open

        parent::__construct($handler);

Call to method __construct from undeclared class \icms_db_criteria_Item
Open

            $criteria->add(new icms_db_criteria_Item("rank_id", $rank_id));

Call to method add from undeclared class \icms_db_criteria_Compo
Open

            $criteria->add(new icms_db_criteria_Item("rank_id", $rank_id));

Call to method __construct from undeclared class \icms_db_criteria_Item
Open

            $criteria->add(new icms_db_criteria_Item("rank_special", "0"));

Call to undeclared method \SystemUserrank::quickInitVar
Open

        $this->quickInitVar("rank_max", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MAX, _CO_ICMS_USERRANK_RANK_MAX_DSC);

Reference to undeclared property \SystemUserrankHandler->table
Open

        $sql = "SELECT rank_image FROM " . $this->table;

Call to undeclared method \SystemUserrank::id
Open

        $ret = '<a href="' . ICMS_MODULES_URL . '/system/admin.php?fct=userrank&amp;op=clone&amp;rank_id=' . $this->id() . '"><img src="' . ICMS_IMAGES_SET_URL . '/actions/editcopy.png" style="vertical-align: middle;" alt="' . _CO_ICMS_CUSTOMTAG_CLONE . '" title="' . _CO_ICMS_CUSTOMTAG_CLONE . '" /></a>';

Return type of getRankPicture() is undeclared type \str
Open

    public function getRankPicture() {

Call to undeclared method \SystemUserrank::quickInitVar
Open

        $this->quickInitVar("rank_min", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MIN, _CO_ICMS_USERRANK_RANK_MIN_DSC);

Call to undeclared method \SystemUserrank::quickInitVar
Open

        $this->quickInitVar("rank_image", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_IMAGE, _CO_ICMS_USERRANK_RANK_IMAGE_DSC);

Call to undeclared method \SystemUserrank::quickInitVar
Open

        $this->quickInitVar("rank_title", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_TITLE, _CO_ICMS_USERRANK_RANK_TITLE_DSC);

Reference to undeclared property \SystemUserrankHandler->table
Open

        $this->table = $this->db->prefix("ranks");

Call to undeclared method \SystemUserrankHandler::enableUpload
Open

        $this->enableUpload(array("image/gif", "image/jpeg", "image/pjpeg", "image/x-png", "image/png"), $icmsConfigUser["rank_maxsize"], $icmsConfigUser["rank_width"], $icmsConfigUser["rank_height"]);

Call to undeclared method \SystemUserrankHandler::getObjects
Open

        $ranks = $this->getObjects($criteria);

Call to method add from undeclared class \icms_db_criteria_Compo
Open

            $criteria->add(new icms_db_criteria_Item("rank_special", "0"));

Returning type string but getCloneLink() is declared to return \str
Open

        return $ret;

Returning type string but getRankPicture() is declared to return \str
Open

        return $ret;

Return type of getRankTitle() is undeclared type \str
Open

    public function getRankTitle() {

Return type of getCloneLink() is undeclared type \str
Open

    public function getCloneLink() {

Class extends undeclared class \icms_ipf_Handler
Open

class SystemUserrankHandler extends icms_ipf_Handler {

Call to undeclared method \SystemUserrank::quickInitVar
Open

        $this->quickInitVar("rank_special", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_SPECIAL, _CO_ICMS_USERRANK_RANK_SPECIAL_DSC);

Reference to undeclared class \icms_ipf_Handler
Open

        parent::__construct($db, "userrank", "rank_id", "rank_title", "", "system");

Call to method add from undeclared class \icms_db_criteria_Compo
Open

            $criteria->add(new icms_db_criteria_Item("rank_max", $posts, ">="));

Call to method add from undeclared class \icms_db_criteria_Compo
Open

            $criteria->add(new icms_db_criteria_Item("rank_min", $posts, "<="));

Call to undeclared method \SystemUserrankHandler::getImagePath
Open

                icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value);

Class extends undeclared class \icms_ipf_Object
Open

class SystemUserrank extends icms_ipf_Object {

Reference to undeclared property \SystemUserrankHandler->db (Did you mean $db)
Open

        $this->table = $this->db->prefix("ranks");

Call to method __construct from undeclared class \icms_db_criteria_Item
Open

            $criteria->add(new icms_db_criteria_Item("rank_max", $posts, ">="));

Call to undeclared method \SystemUserrankHandler::query
Open

        $Query = $this->query($sql, FALSE);

Reference to undeclared constant \XOBJ_DTYPE_INT
Open

        $this->quickInitVar("rank_max", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MAX, _CO_ICMS_USERRANK_RANK_MAX_DSC);

Variable $values was undeclared, but array fields are being added to it.
Open

            $values[] = $Query[$i]["rank_image"];

Call to undeclared method \SystemUserrank::setControl
Open

        $this->setControl("rank_image", "image");

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class SystemUserrank extends icms_ipf_Object {

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class SystemUserrankHandler extends icms_ipf_Handler {

The parameter $rank_id is not named in camelCase.
Open

    public function getRank($rank_id = 0, $posts = 0) {
        $rank_id = (int) $rank_id;
        $posts = (int) $posts;

        $criteria = new icms_db_criteria_Compo();

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

Avoid variables with short names like $db. Configured minimum length is 3.
Open

    public function __construct($db) {

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Each class must be in a file by itself
Open

class SystemUserrankHandler extends icms_ipf_Handler {

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

    public $content = FALSE;

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

    public $objects = FALSE;

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        $this->quickInitVar("rank_id", XOBJ_DTYPE_INT, TRUE);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        $this->quickInitVar("rank_max", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MAX, _CO_ICMS_USERRANK_RANK_MAX_DSC);

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

        $Query = $this->query($sql, FALSE);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        $this->quickInitVar("rank_min", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MIN, _CO_ICMS_USERRANK_RANK_MIN_DSC);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        $this->quickInitVar("rank_title", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_TITLE, _CO_ICMS_USERRANK_RANK_TITLE_DSC);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

icms_loadLanguageFile("system", "userrank", TRUE);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        $this->quickInitVar("rank_image", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_IMAGE, _CO_ICMS_USERRANK_RANK_IMAGE_DSC);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        $this->quickInitVar("rank_special", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_SPECIAL, _CO_ICMS_USERRANK_RANK_SPECIAL_DSC);

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        return TRUE;

Method name "SystemUserrankHandler::MoveAllRanksImagesToProperPath" is not in camel caps format
Open

    public function MoveAllRanksImagesToProperPath() {

Space before opening parenthesis of function call prohibited
Open

defined("ICMS_ROOT_PATH") or die ("ImpressCMS root path not defined");

The variable $Query is not named in camelCase.
Open

    public function MoveAllRanksImagesToProperPath() {
        $sql = "SELECT rank_image FROM " . $this->table;
        $Query = $this->query($sql, FALSE);
        for ($i = 0; $i < count($Query); $i++) {
            $values[] = $Query[$i]["rank_image"];

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $rank_id is not named in camelCase.
Open

    public function getRank($rank_id = 0, $posts = 0) {
        $rank_id = (int) $rank_id;
        $posts = (int) $posts;

        $criteria = new icms_db_criteria_Compo();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $rank_id is not named in camelCase.
Open

    public function getRank($rank_id = 0, $posts = 0) {
        $rank_id = (int) $rank_id;
        $posts = (int) $posts;

        $criteria = new icms_db_criteria_Compo();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $rank_id is not named in camelCase.
Open

    public function getRank($rank_id = 0, $posts = 0) {
        $rank_id = (int) $rank_id;
        $posts = (int) $posts;

        $criteria = new icms_db_criteria_Compo();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $Query is not named in camelCase.
Open

    public function MoveAllRanksImagesToProperPath() {
        $sql = "SELECT rank_image FROM " . $this->table;
        $Query = $this->query($sql, FALSE);
        for ($i = 0; $i < count($Query); $i++) {
            $values[] = $Query[$i]["rank_image"];

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $rank_id is not named in camelCase.
Open

    public function getRank($rank_id = 0, $posts = 0) {
        $rank_id = (int) $rank_id;
        $posts = (int) $posts;

        $criteria = new icms_db_criteria_Compo();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $rank_id is not named in camelCase.
Open

    public function getRank($rank_id = 0, $posts = 0) {
        $rank_id = (int) $rank_id;
        $posts = (int) $posts;

        $criteria = new icms_db_criteria_Compo();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $Query is not named in camelCase.
Open

    public function MoveAllRanksImagesToProperPath() {
        $sql = "SELECT rank_image FROM " . $this->table;
        $Query = $this->query($sql, FALSE);
        for ($i = 0; $i < count($Query); $i++) {
            $values[] = $Query[$i]["rank_image"];

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method MoveAllRanksImagesToProperPath is not named in camelCase.
Open

    public function MoveAllRanksImagesToProperPath() {
        $sql = "SELECT rank_image FROM " . $this->table;
        $Query = $this->query($sql, FALSE);
        for ($i = 0; $i < count($Query); $i++) {
            $values[] = $Query[$i]["rank_image"];

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status