qcubed/framework

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

Summary

Maintainability
A
0 mins
Test Coverage

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

        return $params;

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 '$params' which will lead to PHP notices.
Open

        $params['data-value'] = $strKey;

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 '27').
Open

        $this->dtgPersons = new QDataGrid($this, 'dtgPersons');

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

Missing class import via use statement (line '27', column '36').
Open

        $this->dtgPersons->AddAction(new QCellClickEvent(0, null, QCellClickEvent::RowDataValue('value')), new QAjaxAction('dtgPersonsRow_Click'));

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

Missing class import via use statement (line '27', column '106').
Open

        $this->dtgPersons->AddAction(new QCellClickEvent(0, null, QCellClickEvent::RowDataValue('value')), new QAjaxAction('dtgPersonsRow_Click'));

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 assigning values to variables in if clauses and the like (line '40', column '10').
Open

    protected function dtgPersons_Bind() {
        $clauses = [];
        if ($clause = $this->dtgPersons->OrderByClause) {
            $clauses[] = $this->dtgPersons->OrderByClause;
        }

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

Avoid using static access to class 'Person' in method 'dtgPersonsRow_Click'.
Open

            $objPerson = Person::Load($intPersonId);

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 'Person' in method 'dtgPersons_Bind'.
Open

        $this->dtgPersons->DataSource = Person::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

Avoid using static access to class 'QApplication' in method 'dtgPersonsRow_Click'.
Open

            QApplication::DisplayAlert("You clicked on a person with ID #" . $intPersonId .
                ": " . $objPerson->FirstName . " " . $objPerson->LastName);

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 'QCellClickEvent' in method 'Form_Create'.
Open

        $this->dtgPersons->AddAction(new QCellClickEvent(0, null, QCellClickEvent::RowDataValue('value')), new QAjaxAction('dtgPersonsRow_Click'));

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 '$strFormId'.
Open

    public function dtgPersonsRow_Click($strFormId, $strControlId, $strParameter) {

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

Avoid unused local variables such as '$clause'.
Open

        if ($clause = $this->dtgPersons->OrderByClause) {

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 '$strControlId'.
Open

    public function dtgPersonsRow_Click($strFormId, $strControlId, $strParameter) {

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

Avoid unused parameters such as '$intRowIndex'.
Open

    public function dtgPersons_GetRowParams($objRowObject, $intRowIndex) {

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 method Form_Create is not named in camelCase.
Open

    protected function Form_Create() {
        // Define the DataGrid
        $this->dtgPersons = new QDataGrid($this, 'dtgPersons');

        // Style this with a QCubed built-in style that will highlight the row hovered over.

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 dtgPersons_GetRowParams is not named in camelCase.
Open

    public function dtgPersons_GetRowParams($objRowObject, $intRowIndex) {
        $strKey = $objRowObject->PrimaryKey();
        $params['data-value'] = $strKey;
        return $params;
    }

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 dtgPersonsRow_Click is not named in camelCase.
Open

    public function dtgPersonsRow_Click($strFormId, $strControlId, $strParameter) {
        if ($strParameter) {    // No parameter means the table header was clicked on
            $intPersonId = intval($strParameter);

            $objPerson = Person::Load($intPersonId);

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 dtgPersons_Bind is not named in camelCase.
Open

    protected function dtgPersons_Bind() {
        $clauses = [];
        if ($clause = $this->dtgPersons->OrderByClause) {
            $clauses[] = $this->dtgPersons->OrderByClause;
        }

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 DisplayFullName is not named in camelCase.
Open

    public function DisplayFullName(Person $objPerson) {
        $strToReturn = sprintf('%s, %s', $objPerson->LastName, $objPerson->FirstName);
        return $strToReturn;
    }

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