YetiForceCompany/YetiForceCRM

View on GitHub
modules/Products/models/TreeView.php

Summary

Maintainability
A
0 mins
Test Coverage
F
11%

Avoid using static access to class 'Vtiger_ListView_Model' in method 'getRecords'.
Open

        $listViewModel = Vtiger_ListView_Model::getInstance($this->getModuleName());
Severity: Minor
Found in modules/Products/models/TreeView.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

Returning type array but getTreeList() is declared to return string
Open

        return array_merge(parent::getTreeList(), $this->getRecords());
Severity: Minor
Found in modules/Products/models/TreeView.php by phan

Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $listViewModel->getQueryGenerator()->setFields(['id', 'pscategory']);
Severity: Critical
Found in modules/Products/models/TreeView.php by phan

Reference to undeclared property \Products_TreeView_Model->lastTreeId
Open

                'id' => $this->lastTreeId,
Severity: Minor
Found in modules/Products/models/TreeView.php by phan

Argument 1 (arr1) is string but \array_merge() takes array
Open

        return array_merge(parent::getTreeList(), $this->getRecords());
Severity: Minor
Found in modules/Products/models/TreeView.php by phan

Reference to undeclared property \Products_TreeView_Model->lastTreeId
Open

            ++$this->lastTreeId;
Severity: Minor
Found in modules/Products/models/TreeView.php by phan

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Products_TreeView_Model extends Vtiger_TreeView_Model

The class Products_TreeView_Model is not named in CamelCase.
Open

class Products_TreeView_Model extends Vtiger_TreeView_Model
{
    /** {@inheritdoc} */
    public function isActive()
    {
Severity: Minor
Found in modules/Products/models/TreeView.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * Load tree.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            $parent = (int) str_replace('T', '', $parent);

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                'text' => $item->getName(),

Spaces must be used to indent lines; tabs are not allowed
Open

        return $tree;

Spaces must be used to indent lines; tabs are not allowed
Open

    private function getRecords(): array

Spaces must be used to indent lines; tabs are not allowed
Open

        $tree = [];

Spaces must be used to indent lines; tabs are not allowed
Open

            ++$this->lastTreeId;

Spaces must be used to indent lines; tabs are not allowed
Open

            $parent = $item->get('pscategory');

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

                'type' => 'record',

Spaces must be used to indent lines; tabs are not allowed
Open

            ];

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            $tree[] = [

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getTreeList()

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $listViewModel = Vtiger_ListView_Model::getInstance($this->getModuleName());

Spaces must be used to indent lines; tabs are not allowed
Open

        $listViewModel->getQueryGenerator()->setFields(['id', 'pscategory']);

Spaces must be used to indent lines; tabs are not allowed
Open

                'id' => $this->lastTreeId,

Spaces must be used to indent lines; tabs are not allowed
Open

        return true;

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * Gets tree records.

Spaces must be used to indent lines; tabs are not allowed
Open

                'record_id' => $item->getId(),

Spaces must be used to indent lines; tabs are not allowed
Open

                'isrecord' => true,

Spaces must be used to indent lines; tabs are not allowed
Open

                'state' => [],

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isActive()

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($listViewModel->getAllEntries() as $item) {

Spaces must be used to indent lines; tabs are not allowed
Open

                'parent' => 0 == $parent ? '#' : $parent,

Spaces must be used to indent lines; tabs are not allowed
Open

                'icon' => 'fas fa-file',

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

        return array_merge(parent::getTreeList(), $this->getRecords());

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Class name "Products_TreeView_Model" is not in camel caps format
Open

class Products_TreeView_Model extends Vtiger_TreeView_Model

There are no issues that match your filters.

Category
Status