Avoid using static access to class 'CRMEntity' in method 'getHierarchy'. Open
$focus = CRMEntity::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
Avoid using static access to class 'Vtiger_Record_Model' in method 'getHierarchy'. Open
$recordModel = Vtiger_Record_Model::getCleanInstance('MultiCompany');
- 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
Avoid using static access to class '\App\MultiCompany' in method 'privilegeToDelete'. Open
$this->privileges['Deleted'] = parent::privilegeToDelete() && !\App\MultiCompany::getRolesByCompany($this->getId());
- 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
Avoid using static access to class '\App\UserPrivilegesFile' in method 'save'. Open
\App\UserPrivilegesFile::reloadByMultiCompany($this->getId());
- 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
Avoid using static access to class '\App\MultiCompany' in method 'privilegeToMoveToTrash'. Open
$this->privileges['MoveToTrash'] = parent::privilegeToMoveToTrash() && !\App\MultiCompany::getRolesByCompany($this->getId());
- 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
Define a constant instead of duplicating this literal "Deleted" 3 times. Open
if (!isset($this->privileges['Deleted'])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "MoveToTrash" 3 times. Open
if (!isset($this->privileges['MoveToTrash'])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to undeclared method \CRMEntity::getHierarchy
Open
$hierarchy = $focus->getHierarchy($this->getId());
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class MultiCompany_Record_Model extends Vtiger_Record_Model
- Exclude checks
The class MultiCompany_Record_Model is not named in CamelCase. Open
class MultiCompany_Record_Model extends Vtiger_Record_Model
{
/** {@inheritdoc} */
public function getHierarchy()
{
- 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
$hierarchy = $focus->getHierarchy($this->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== $this->getPreviousValue('logo')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/[.\s]+/', $storageInfo[0], $dashes);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($hierarchy['entries'] as $id => $storageInfo) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($matches)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$hierarchy['entries'][$id][0] = ($dashes[0] ?? '') . '<a href=' . $recordModel->getDetailViewUrl() . '>' . $name[2] . '</a>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->privileges['MoveToTrash'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->privileges['Deleted'] = parent::privilegeToDelete() && !\App\MultiCompany::getRolesByCompany($this->getId());
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$this->privileges['Deleted'] = parent::privilegeToDelete() && !\App\MultiCompany::getRolesByCompany($this->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/<a href="+/', $storageInfo[0], $matches);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = Vtiger_Record_Model::getCleanInstance('MultiCompany');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->privileges['Deleted'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$focus = CRMEntity::getInstance($this->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $hierarchy;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function privilegeToMoveToTrash()
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
$this->privileges['MoveToTrash'] = parent::privilegeToMoveToTrash() && !\App\MultiCompany::getRolesByCompany($this->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
$hierarchy['entries'][$id][0] = ($dashes[0] ?? '') . '<a href=' . $recordModel->getDetailViewUrl() . '>' . $name[2] . '</a>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->privileges['MoveToTrash'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function privilegeToDelete()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getHierarchy()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->setId($id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\UserPrivilegesFile::reloadByMultiCompany($this->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/<a(.*)>(.*)<\\/a>/i', $storageInfo[0], $name);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function save()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->privileges['Deleted'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->privileges['MoveToTrash'] = parent::privilegeToMoveToTrash() && !\App\MultiCompany::getRolesByCompany($this->getId());
- Exclude checks
Class name "MultiCompany_Record_Model" is not in camel caps format Open
class MultiCompany_Record_Model extends Vtiger_Record_Model
- Exclude checks