Missing class import via use statement (line '128', column '23'). Open
$criteria->add(new icms_db_criteria_Item("rank_special", "0"));
- Read upRead up
- Exclude checks
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, "<="));
- Read upRead up
- Exclude checks
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));
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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, ">="));
- Read upRead up
- Exclude checks
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"));
- 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 'icms_core_Filesystem' in method 'MoveAllRanksImagesToProperPath'. Open
icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value);
- 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
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"));
}
- 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 count() function in for loops. Open
for ($i = 0; $i < count($Query); $i++) {
$values[] = $Query[$i]["rank_image"];
}
- Read upRead up
- Exclude checks
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);
- Exclude checks
Reference to undeclared class \icms_ipf_Object
Open
return parent::getVar($key, $format);
- Exclude checks
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);
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Item
Open
$criteria->add(new icms_db_criteria_Item("rank_min", $posts, "<="));
- Exclude checks
Call to undeclared method \SystemUserrankHandler::getImageUrl
Open
"image" => $this->getImageUrl() . $ranks[0]->getVar("rank_image"));
- Exclude checks
Call to undeclared method \SystemUserrank::setControl
Open
$this->setControl("rank_special", "yesno");
- Exclude checks
Reference to undeclared property \SystemUserrank->handler
Open
$ret = '<img src="' . $this->handler->getImageUrl() . $this->getVar("rank_image") . '" />';
- Exclude checks
Call to method copyRecursive
from undeclared class \icms_core_Filesystem
Open
icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value);
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_INT
Open
$this->quickInitVar("rank_id", XOBJ_DTYPE_INT, TRUE);
- Exclude checks
Call to undeclared method \SystemUserrank::quickInitVar
Open
$this->quickInitVar("rank_id", XOBJ_DTYPE_INT, TRUE);
- Exclude checks
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);
- Exclude checks
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);
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Compo
Open
$criteria = new icms_db_criteria_Compo();
- Exclude checks
Reference to undeclared class \icms_ipf_Object
Open
parent::__construct($handler);
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Item
Open
$criteria->add(new icms_db_criteria_Item("rank_id", $rank_id));
- Exclude checks
Call to method add
from undeclared class \icms_db_criteria_Compo
Open
$criteria->add(new icms_db_criteria_Item("rank_id", $rank_id));
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Item
Open
$criteria->add(new icms_db_criteria_Item("rank_special", "0"));
- Exclude checks
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);
- Exclude checks
Reference to undeclared property \SystemUserrankHandler->table
Open
$sql = "SELECT rank_image FROM " . $this->table;
- Exclude checks
Call to undeclared method \SystemUserrank::id
Open
$ret = '<a href="' . ICMS_MODULES_URL . '/system/admin.php?fct=userrank&op=clone&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>';
- Exclude checks
Return type of getRankPicture()
is undeclared type \str
Open
public function getRankPicture() {
- Exclude checks
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);
- Exclude checks
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);
- Exclude checks
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);
- Exclude checks
Reference to undeclared property \SystemUserrankHandler->table
Open
$this->table = $this->db->prefix("ranks");
- Exclude checks
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"]);
- Exclude checks
Call to undeclared method \SystemUserrankHandler::getObjects
Open
$ranks = $this->getObjects($criteria);
- Exclude checks
Call to method add
from undeclared class \icms_db_criteria_Compo
Open
$criteria->add(new icms_db_criteria_Item("rank_special", "0"));
- Exclude checks
Returning type string
but getCloneLink()
is declared to return \str
Open
return $ret;
- Exclude checks
Returning type string
but getRankPicture()
is declared to return \str
Open
return $ret;
- Exclude checks
Return type of getRankTitle()
is undeclared type \str
Open
public function getRankTitle() {
- Exclude checks
Return type of getCloneLink()
is undeclared type \str
Open
public function getCloneLink() {
- Exclude checks
Class extends undeclared class \icms_ipf_Handler
Open
class SystemUserrankHandler extends icms_ipf_Handler {
- Exclude checks
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);
- Exclude checks
Reference to undeclared class \icms_ipf_Handler
Open
parent::__construct($db, "userrank", "rank_id", "rank_title", "", "system");
- Exclude checks
Call to method add
from undeclared class \icms_db_criteria_Compo
Open
$criteria->add(new icms_db_criteria_Item("rank_max", $posts, ">="));
- Exclude checks
Call to method add
from undeclared class \icms_db_criteria_Compo
Open
$criteria->add(new icms_db_criteria_Item("rank_min", $posts, "<="));
- Exclude checks
Call to undeclared method \SystemUserrankHandler::getImagePath
Open
icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value);
- Exclude checks
Class extends undeclared class \icms_ipf_Object
Open
class SystemUserrank extends icms_ipf_Object {
- Exclude checks
Reference to undeclared property \SystemUserrankHandler->db
(Did you mean $db) Open
$this->table = $this->db->prefix("ranks");
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Item
Open
$criteria->add(new icms_db_criteria_Item("rank_max", $posts, ">="));
- Exclude checks
Call to undeclared method \SystemUserrankHandler::query
Open
$Query = $this->query($sql, FALSE);
- Exclude checks
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);
- Exclude checks
Variable $values
was undeclared, but array fields are being added to it. Open
$values[] = $Query[$i]["rank_image"];
- Exclude checks
Call to undeclared method \SystemUserrank::setControl
Open
$this->setControl("rank_image", "image");
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class SystemUserrank extends icms_ipf_Object {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class SystemUserrankHandler extends icms_ipf_Handler {
- Exclude checks
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();
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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 {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
public $content = FALSE;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
public $objects = FALSE;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$this->quickInitVar("rank_id", XOBJ_DTYPE_INT, TRUE);
- Exclude checks
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);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
$Query = $this->query($sql, FALSE);
- Exclude checks
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);
- Exclude checks
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);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
icms_loadLanguageFile("system", "userrank", TRUE);
- Exclude checks
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);
- Exclude checks
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);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
return TRUE;
- Exclude checks
Method name "SystemUserrankHandler::MoveAllRanksImagesToProperPath" is not in camel caps format Open
public function MoveAllRanksImagesToProperPath() {
- Exclude checks
Space before opening parenthesis of function call prohibited Open
defined("ICMS_ROOT_PATH") or die ("ImpressCMS root path not defined");
- Exclude checks
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"];
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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"];
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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"];
- Read upRead up
- Exclude checks
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"];
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}