mambax7/adslight

View on GitHub
include/comment_functions.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using static access to class '\XoopsDatabaseFactory' in method 'adslight_com_update'.
Open

        $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
Severity: Minor
Found in include/comment_functions.php by phpmd

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

    function adslight_com_approve(&$comment): void
Severity: Minor
Found in include/comment_functions.php by phpmd

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

    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}";
Severity: Minor
Found in include/comment_functions.php by phpmd

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

<?php declare(strict_types=1);

Line exceeds 120 characters; contains 122 characters
Open

        $sql     = 'UPDATE ' . $xoopsDB->prefix('adslight_listing') . " SET comments = {$total_num} WHERE usid = {$usid}";

The variable $total_num is not named in camelCase.
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}";
Severity: Minor
Found in include/comment_functions.php by phpmd

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

There are no issues that match your filters.

Category
Status