modules/Products/models/TreeView.php
Avoid using static access to class 'Vtiger_ListView_Model' in method 'getRecords'. Open
Open
$listViewModel = Vtiger_ListView_Model::getInstance($this->getModuleName());
- 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
Returning type array
but getTreeList()
is declared to return string
Open
Open
return array_merge(parent::getTreeList(), $this->getRecords());
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
Open
$listViewModel->getQueryGenerator()->setFields(['id', 'pscategory']);
- Exclude checks
Reference to undeclared property \Products_TreeView_Model->lastTreeId
Open
Open
'id' => $this->lastTreeId,
- Exclude checks
Argument 1 (arr1)
is string
but \array_merge()
takes array
Open
Open
return array_merge(parent::getTreeList(), $this->getRecords());
- Exclude checks
Reference to undeclared property \Products_TreeView_Model->lastTreeId
Open
Open
++$this->lastTreeId;
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Products_TreeView_Model extends Vtiger_TreeView_Model
- Exclude checks
The class Products_TreeView_Model is not named in CamelCase. Open
Open
class Products_TreeView_Model extends Vtiger_TreeView_Model
{
/** {@inheritdoc} */
public function isActive()
{
- Read upRead up
- Exclude checks
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
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Load tree.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$parent = (int) str_replace('T', '', $parent);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'text' => $item->getName(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $tree;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
private function getRecords(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$tree = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
++$this->lastTreeId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$parent = $item->get('pscategory');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'type' => 'record',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$tree[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getTreeList()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$listViewModel = Vtiger_ListView_Model::getInstance($this->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$listViewModel->getQueryGenerator()->setFields(['id', 'pscategory']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'id' => $this->lastTreeId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Gets tree records.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'record_id' => $item->getId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'isrecord' => true,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'state' => [],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function isActive()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach ($listViewModel->getAllEntries() as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'parent' => 0 == $parent ? '#' : $parent,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'icon' => 'fas fa-file',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return array_merge(parent::getTreeList(), $this->getRecords());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Class name "Products_TreeView_Model" is not in camel caps format Open
Open
class Products_TreeView_Model extends Vtiger_TreeView_Model
- Exclude checks