qcubed/framework

View on GitHub
assets/php/examples/datagrid/column_values.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using undefined variables such as '$ret' which will lead to PHP notices.
Open

            $ret['style'] = 'color:red';

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$ret' which will lead to PHP notices.
Open

        $ret['class'] ='amount';

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$ret' which will lead to PHP notices.
Open

        return $ret;

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Missing class import via use statement (line '11', column '28').
Open

        $this->tblProjects = new QHtmlTable($this);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid using static access to class 'QQ' in method 'tblProjects_Bind'.
Open

        $clauses = QQ::ExpandAsArray(QQN::Project()->PersonAsTeamMember);

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

The method RenderTeamMemberArray uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        else {
            return '';
        }

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

Avoid using static access to class 'Project' in method 'tblProjects_Bind'.
Open

        $this->tblProjects->DataSource = Project::LoadAll($clauses);

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

The method dtgPerson_BalanceRender uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        else {
            return number_format($val);
        }

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

Avoid variables with short names like $a. Configured minimum length is 3.
Open

    public static function RenderTeamMemberArray($a) {

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

The method tblProjects_Bind is not named in camelCase.
Open

    protected function tblProjects_Bind() {
        // Expand the PersonAsTeamMember node as an array so that it will be included in each item sent to the columns.
        $clauses = QQ::ExpandAsArray(QQN::Project()->PersonAsTeamMember);

        // We load the data source, and set it to the datagrid's DataSource parameter

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method RenderTeamMemberArray is not named in camelCase.
Open

    public static function RenderTeamMemberArray($a) {
        if ($a) {
            return implode(', ',
                array_map(function($val) {return $val->FirstName . ' ' . $val->LastName; }, $a));
        }

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method dtgPerson_BalanceRender is not named in camelCase.
Open

    public function dtgPerson_BalanceRender($item) {
        $val = $item->Budget - $item->Spent;
        if ($val < 0) {
            return '(' . number_format(-$val) . ')';
        }

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method Form_Create is not named in camelCase.
Open

    protected function Form_Create() {
        // Define the DataGrid
        $this->tblProjects = new QHtmlTable($this);

        // This css class is used to style alternate rows and the header, all in css

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method dtgPerson_BalanceAttributes is not named in camelCase.
Open

    public function dtgPerson_BalanceAttributes($item)
    {
        $ret['class'] ='amount';
        $val = $item->Budget - $item->Spent;

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status