htdocs/modules/system/admin/blockspadmin/main.php
The method editblockposition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$sform = $blockObj->getForm(_AM_SYSTEM_BLOCKSPADMIN_CREATE, 'addblockposition');
$sform->assign($icmsAdminTpl);
}
- 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
Reference to undeclared constant \_NOPERM
Open
Open
exit(_NOPERM);
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('pname'), 'center');
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
Open
$icmsAdminTpl->assign('icms_blockposition_table', $objectTable->fetch());
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
Open
$icmsAdminTpl->assign('lang_badmin', _AM_SYSTEM_BLOCKSPADMIN_TITLE);
- Exclude checks
Reference to static property user
from undeclared class \icms
Open
Open
if (!is_object(icms::$user) || !is_object($icmsModule) || !icms::$user->isAdmin($icmsModule->getVar('mid'))) {
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_Controller
Open
Open
$controller = new icms_ipf_Controller($icms_blockposition_handler);
- Exclude checks
Call to method storeFromDefaultForm
from undeclared class \icms_ipf_Controller
Open
Open
$controller->storeFromDefaultForm(_AM_SYSTEM_BLOCKSPADMIN_CREATED, _AM_SYSTEM_BLOCKSPADMIN_MODIFIED);
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('description'));
- Exclude checks
Call to method addQuickSearch
from undeclared class \icms_ipf_view_Table
Open
Open
$objectTable->addQuickSearch(array('pname', 'title', 'description'));
- Exclude checks
Call to method fetch
from undeclared class \icms_ipf_view_Table
Open
Open
$icmsAdminTpl->assign('icms_blockposition_table', $objectTable->fetch());
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Column
Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', FALSE, FALSE, 'getCustomTitle', FALSE, FALSE, FALSE));
- Exclude checks
Call to method handleObjectDeletion
from undeclared class \icms_ipf_Controller
Open
Open
$controller->handleObjectDeletion();
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('pname'), 'center');
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
Open
$icmsAdminTpl->assign('icms_blockposition_info', _AM_SYSTEM_BLOCKSPADMIN_INFO);
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', FALSE, FALSE, 'getCustomTitle', FALSE, FALSE, FALSE));
- Exclude checks
Call to method addIntroButton
from undeclared class \icms_ipf_view_Table
Open
Open
$objectTable->addIntroButton('addblockposition', 'admin.php?fct=blockspadmin&op=mod', _AM_SYSTEM_BLOCKSPADMIN_CREATE);
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_Controller
Open
Open
$controller = new icms_ipf_Controller($icms_blockposition_handler);
- Exclude checks
Call to method addColumn
from undeclared class \icms_ipf_view_Table
Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('description'));
- Exclude checks
Variable $icmsModule
is undeclared Open
Open
if (!is_object(icms::$user) || !is_object($icmsModule) || !icms::$user->isAdmin($icmsModule->getVar('mid'))) {
- Exclude checks
Call to method __construct
from undeclared class \icms_ipf_view_Table
Open
Open
$objectTable = new icms_ipf_view_Table($icms_blockposition_handler, FALSE);
- Exclude checks
Variable $icmsAdminTpl
is undeclared Open
Open
$icmsAdminTpl->display('db:system_adm_blockspadmin.html');
- Exclude checks
Avoid excessively long variable names like $icms_blockposition_handler. Keep variable name length under 20. Open
Open
global $icms_blockposition_handler, $icmsAdminTpl;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
Open
function editblockposition($id = 0) {
- 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
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', FALSE, FALSE, 'getCustomTitle', FALSE, FALSE, FALSE));
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
Open
if (in_array($clean_op, $valid_op, TRUE)) {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', FALSE, FALSE, 'getCustomTitle', FALSE, FALSE, FALSE));
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
Open
$objectTable = new icms_ipf_view_Table($icms_blockposition_handler, FALSE);
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case "changedField":
- Exclude checks
Blank line found at end of control structure Open
Open
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', FALSE, FALSE, 'getCustomTitle', FALSE, FALSE, FALSE));
- Exclude checks
Blank line found at end of control structure Open
Open
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', FALSE, FALSE, 'getCustomTitle', FALSE, FALSE, FALSE));
- Exclude checks
Blank line found at start of control structure Open
Open
if (in_array($clean_op, $valid_op, TRUE)) {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
Open
$objectTable->addColumn(new icms_ipf_view_Column('title', FALSE, FALSE, 'getCustomTitle', FALSE, FALSE, FALSE));
- Exclude checks
Inline control structures are not allowed Open
Open
if (isset($_POST['op'])) $clean_op = htmlentities($_POST['op']);
- Exclude checks
Inline control structures are not allowed Open
Open
if (isset($_GET['op'])) $clean_op = htmlentities($_GET['op']);
- Exclude checks
The variable $icms_blockposition_handler is not named in camelCase. Open
Open
function editblockposition($id = 0) {
global $icms_blockposition_handler, $icmsAdminTpl;
$blockObj = $icms_blockposition_handler->get($id);
- 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 $icms_blockposition_handler is not named in camelCase. Open
Open
function editblockposition($id = 0) {
global $icms_blockposition_handler, $icmsAdminTpl;
$blockObj = $icms_blockposition_handler->get($id);
- 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();
}
}