xoops_module_pre_install_adslight accesses the super-global variable $GLOBALS. Open
function xoops_module_pre_install_adslight(\XoopsModule $module): bool
{
require_once __DIR__ . '/common.php';
$utility = new Utility();
//check for minimum XOOPS version
- 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
xoops_module_pre_install_adslight accesses the super-global variable $GLOBALS. Open
function xoops_module_pre_install_adslight(\XoopsModule $module): bool
{
require_once __DIR__ . '/common.php';
$utility = new Utility();
//check for minimum XOOPS version
- 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 xoops_module_install_adslight
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function xoops_module_install_adslight(\XoopsModule $module): bool
{
require_once \dirname(__DIR__, 3) . '/mainfile.php';
global $xoopsDB;
Function xoops_module_install_adslight
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function xoops_module_install_adslight(\XoopsModule $module): bool
{
require_once \dirname(__DIR__, 3) . '/mainfile.php';
global $xoopsDB;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid unused local variables such as '$rowsCount'. Open
$rowsCount = $xoopsDB->getRowsNum($xoopsDB->query($sql));
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused parameters such as '$module'. Open
function xoops_module_install_adslight(\XoopsModule $module): bool
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
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 31 and the first side effect is on line 23. Open
<?php declare(strict_types=1);
- Exclude checks
There must be one USE keyword per declaration Open
use XoopsModules\Adslight\{
- Exclude checks