Avoid using static access to class 'App\Json' in method 'getUrl'. Open
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
- 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
The method getSearchParams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$values = Calendar_Module_Model::getComponentActivityStateLabel('current');
}
- Read upRead up
- Exclude checks
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 '\App\Json' in method 'getWidget'. Open
$this->Config['switchTypeInHeader']['off'] = \App\Json::encode($this->getSearchParams('history'));
- 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\Relation' in method 'isPermitted'. Open
return parent::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), true, 'Calendar');
- 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_Module_Model' in method 'getWidget'. Open
$model = Vtiger_Module_Model::getInstance('Calendar');
- 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\Language' in method 'getWidget'. Open
$this->Config['switchHeaderLables']['on'] = \App\Language::translate('LBL_CURRENT', $model->getName());
- 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\Language' in method 'getWidget'. Open
$this->Config['switchHeaderLables']['off'] = \App\Language::translate('LBL_HISTORY', $model->getName());
- 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 'Calendar_Module_Model' in method 'getSearchParams'. Open
$values = Calendar_Module_Model::getComponentActivityStateLabel('current');
- 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 'Calendar_Module_Model' in method 'getSearchParams'. Open
$values = Calendar_Module_Model::getComponentActivityStateLabel('history');
- 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\Json' in method 'getWidget'. Open
$this->Config['switchTypeInHeader']['on'] = \App\Json::encode($this->getSearchParams('current'));
- 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\Json' in method 'getUrl'. Open
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
- 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 "switchTypeInHeader" 5 times. Open
if (!isset($this->Data['switchTypeInHeader']) || '-' != $this->Data['switchTypeInHeader']) {
- 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 "current" 3 times. Open
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
- 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 "history" 3 times. Open
$this->Config['switchTypeInHeader']['off'] = \App\Json::encode($this->getSearchParams('history'));
- 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.
Reference to undeclared property \Vtiger_Activities_Widget->Data
Open
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
- Exclude checks
Argument 2 (moduleName)
is false
but \App\Language::translate()
takes string
defined at /code/app/Language.php:161
Open
$this->Config['switchHeaderLables']['on'] = \App\Language::translate('LBL_CURRENT', $model->getName());
- Exclude checks
Call to method getName
on non-class type false
Open
return parent::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), true, 'Calendar');
- Exclude checks
Suspicious type false
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
- Exclude checks
Reference to undeclared property \Vtiger_Activities_Widget->Data
Open
if (!isset($this->Data['switchTypeInHeader']) || '-' != $this->Data['switchTypeInHeader']) {
- Exclude checks
Argument 2 (moduleName)
is false
but \App\Language::translate()
takes string
defined at /code/app/Language.php:161
Open
$this->Config['switchHeaderLables']['off'] = \App\Language::translate('LBL_HISTORY', $model->getName());
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_Activities_Widget extends Vtiger_Basic_Widget
- Exclude checks
The class Vtiger_Activities_Widget is not named in CamelCase. Open
class Vtiger_Activities_Widget extends Vtiger_Basic_Widget
{
/** {@inheritdoc} */
public function isPermitted(): bool
{
- 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
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchTypeInHeader'] = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $widget;
- 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 getWidget()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = $this->Config;
- 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
* Get URL.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchTypeInHeader']['on'] = \App\Json::encode($this->getSearchParams('current'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchHeaderLables']['off'] = \App\Language::translate('LBL_HISTORY', $model->getName());
- 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 [['activitystatus', 'e', implode('##', $values)]];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['tpl'] = 'Activities.tpl';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values = Calendar_Module_Model::getComponentActivityStateLabel('history');
- 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
public function getUrl()
- 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
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- 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 'ActivitiesConfig';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isPermitted(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return parent::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), true, 'Calendar');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($model->isPermitted('DetailView')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->Data['switchTypeInHeader']) || '-' != $this->Data['switchTypeInHeader']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchHeaderLables']['on'] = \App\Language::translate('LBL_CURRENT', $model->getName());
- 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 getSearchParams(string $type): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['switchTypeInHeader']['off'] = \App\Json::encode($this->getSearchParams('history'));
- 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
* Function to get params to searching.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- 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 300 characters Open
return 'module=' . $this->Module . '&view=Detail&record=' . $this->Record . '&mode=getActivities&page=1&limit=' . $this->Data['limit'] . '&search_params=' . App\Json::encode([$this->getSearchParams('current')]) . '&orderby=' . App\Json::encode(['date_start' => 'ASC', 'time_start' => 'ASC']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getConfigTplName()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$model = Vtiger_Module_Model::getInstance('Calendar');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['url'] = $this->getUrl();
- 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
$values = Calendar_Module_Model::getComponentActivityStateLabel('current');
- 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
if ('history' === $type) {
- Exclude checks
Class name "Vtiger_Activities_Widget" is not in camel caps format Open
class Vtiger_Activities_Widget extends Vtiger_Basic_Widget
- Exclude checks