printAd accesses the super-global variable $GLOBALS. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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
printAd accesses the super-global variable $GLOBALS. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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
printAd accesses the super-global variable $GLOBALS. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 printAd
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
Function printAd
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 using static access to class '\XoopsModules\Adslight\Helper' in method 'printAd'. Open
$helper = Helper::getInstance();
- 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
Avoid using static access to class '\XoopsModules\Adslight\Utility' in method 'printAd'. Open
$type = Utility::getNameType(htmlspecialchars($type, ENT_QUOTES | ENT_HTML5));
- 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
Avoid unused local variables such as '$email'. Open
[$lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date_created, $email, $submitter, $town, $country, $photo, $cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($result);
- 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 local variables such as '$cod_img'. Open
[$lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date_created, $email, $submitter, $town, $country, $photo, $cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($result);
- 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 local variables such as '$uid_owner'. Open
[$lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date_created, $email, $submitter, $town, $country, $photo, $cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($result);
- 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 local variables such as '$pic_lid'. Open
[$lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date_created, $email, $submitter, $town, $country, $photo, $cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($result);
- 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 local variables such as '$date1'. Open
$date1 = formatTimestamp($date_created, 's');
- 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
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 36 and the first side effect is on line 30. Open
<?php declare(strict_types=1);
- Exclude checks
There must be one USE keyword per declaration Open
use XoopsModules\Adslight\{
- Exclude checks
Line exceeds 120 characters; contains 200 characters Open
[$lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date_created, $email, $submitter, $town, $country, $photo, $cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($result);
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
echo '<strong>' . _ADSLIGHT_PRICE2 . "</strong> {$price} " . $helper->getConfig('adslight_currency_symbol') . " - {$typeprice}<br>";
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
echo '<br><br>' . _ADSLIGHT_DATE2 . " {$date_created} " . _ADSLIGHT_AND . ' ' . _ADSLIGHT_DISPO . " {$date2}<br><br>";
- Exclude checks
Line exceeds 120 characters; contains 156 characters Open
echo "<tr><td><div style='text-align:left'><img class=\"thumb\" src=\"" . XOOPS_URL . "/uploads/adslight/{$url}\" width=\"130px\" border=0 ></div>";
- Exclude checks
Line exceeds 120 characters; contains 203 characters Open
$sql = 'SELECT l.lid, l.title, l.expire, l.type, l.desctext, l.tel, l.price, l.typeprice, l.date_created, l.email, l.submitter, l.town, l.country, l.photo, p.cod_img, p.lid, p.uid_owner, p.url FROM '
- Exclude checks
The variable $date_created is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 $date_created is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 $uid_owner is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 $pic_lid is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 $date_created is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 $date_created is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 $cod_img is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 $date_created is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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 $date_created is not named in camelCase. Open
function printAd($lid): void
{
global $xoopsConfig, $xoopsDB, $useroffset, $myts;
$helper = Helper::getInstance();
$currenttheme = $xoopsConfig['theme_set'];
- 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();
}
}