Avoid using static access to class '\App\Json' in method 'setDataFromRequest'. Open
$data = $this->get('data') ? \App\Json::decode($this->get('data')) : [];
- 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 'getFieldInstanceByName'. Open
$owners = $this->get('data') ? \App\Json::decode($this->get('data')) : [];
- 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 'setDataFromRequest'. Open
$this->set('data', \App\Json::encode($data));
- 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_Field_Model' in method 'getFieldInstanceByName'. Open
return \Vtiger_Field_Model::init($moduleName, $params, $name);
- 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 "channels" 3 times. Open
if (!isset($this->customFields[$name]) && 'channels' !== $name) {
- 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 class \Vtiger_Widget_Model
Open
parent::setDataFromRequest($request);
- Exclude checks
Class extends undeclared class \Vtiger_Widget_Model
Open
class Vtiger_RssModel_Dashboard extends Vtiger_Widget_Model
- Exclude checks
Reference to undeclared class \Vtiger_Widget_Model
Open
return parent::getFieldInstanceByName($name);
- Exclude checks
Call to undeclared method \Vtiger_RssModel_Dashboard::get
Open
$data = $this->get('data') ? \App\Json::decode($this->get('data')) : [];
- Exclude checks
Reference to undeclared property \Vtiger_RssModel_Dashboard->customFields
Open
if (!isset($this->customFields[$name]) && 'channels' !== $name) {
- Exclude checks
Call to undeclared method \Vtiger_RssModel_Dashboard::set
Open
$this->set('data', \App\Json::encode($data));
- Exclude checks
Reference to undeclared property \Vtiger_RssModel_Dashboard->editFields
Open
return ['title' => ['label' => 'LBL_WIDGET_NAME', 'purifyType' => \App\Purifier::TEXT, 'required' => true]] + $this->editFields;
- Exclude checks
Call to undeclared method \Vtiger_RssModel_Dashboard::get
Open
$owners = $this->get('data') ? \App\Json::decode($this->get('data')) : [];
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_RssModel_Dashboard extends Vtiger_Widget_Model
- Exclude checks
The class Vtiger_RssModel_Dashboard is not named in CamelCase. Open
class Vtiger_RssModel_Dashboard extends Vtiger_Widget_Model
{
/** {@inheritdoc} */
public function getEditFields(): array
{
- 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
The DEFAULT body must start on the line following the statement Open
default: break;
- Exclude checks
Terminating statement must be on a line by itself Open
default: break;
- 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
$moduleName = 'Settings:WidgetsManagement';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['picklistValues'] = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['typeofdata'] = 'V~M';
- 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
$params = [
- 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
$data[$fieldName] = $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->customFields[$name]) && 'channels' !== $name) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $value ? explode(' |##| ', $value) : [];
- 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
'label' => 'LBL_ADDRESS_RSS',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $this->getFieldInstanceByName($fieldName)->getUITypeModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return ['title' => ['label' => 'LBL_WIDGET_NAME', 'purifyType' => \App\Purifier::TEXT, 'required' => true]] + $this->editFields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFieldInstanceByName($name)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($name) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['fieldvalue'] = implode(' |##| ', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::setDataFromRequest($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('data', \App\Json::encode($data));
- 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
$owners = $this->get('data') ? \App\Json::decode($this->get('data')) : [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return parent::getFieldInstanceByName($name);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['uitype'] = 33;
- 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
$value = $owners[$name] ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default: break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldName = 'channels';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $request->getByType($fieldName, \App\Purifier::TEXT);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getEditFields(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \Vtiger_Field_Model::init($moduleName, $params, $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 setDataFromRequest(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->validate($value, true);
- 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
'name' => $name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tooltip' => ''
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->has($fieldName)) {
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
return ['title' => ['label' => 'LBL_WIDGET_NAME', 'purifyType' => \App\Purifier::TEXT, 'required' => true]] + $this->editFields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'channels':
- 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
$value = $fieldModel->getDBValue($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $this->get('data') ? \App\Json::decode($this->get('data')) : [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Closing brace must be on a line by itself Open
default: break;
- Exclude checks
Class name "Vtiger_RssModel_Dashboard" is not in camel caps format Open
class Vtiger_RssModel_Dashboard extends Vtiger_Widget_Model
- Exclude checks