include/comment_functions.php
Avoid using static access to class '\XoopsDatabaseFactory' in method 'adslight_com_update'. Open
Open
$xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
- 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 parameters such as '$comment'. Open
Open
function adslight_com_approve(&$comment): void
- 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
The parameter $total_num is not named in camelCase. Open
Open
function adslight_com_update($usid, $total_num): void
{
/** @var \XoopsMySQLDatabase $xoopsDB */
$xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
$sql = 'UPDATE ' . $xoopsDB->prefix('adslight_listing') . " SET comments = {$total_num} WHERE usid = {$usid}";
- 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
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 30 and the first side effect is on line 24. Open
Open
<?php declare(strict_types=1);
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
$sql = 'UPDATE ' . $xoopsDB->prefix('adslight_listing') . " SET comments = {$total_num} WHERE usid = {$usid}";
- Exclude checks
The variable $total_num is not named in camelCase. Open
Open
function adslight_com_update($usid, $total_num): void
{
/** @var \XoopsMySQLDatabase $xoopsDB */
$xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
$sql = 'UPDATE ' . $xoopsDB->prefix('adslight_listing') . " SET comments = {$total_num} WHERE usid = {$usid}";
- 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();
}
}