Avoid using static access to class '\Vtiger_Record_Model' in method 'doTask'. Open
$cloneRecordModel = \Vtiger_Record_Model::getCleanInstance($recordModel->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 '\App\AutoAssign' in method 'doTask'. Open
$autoAssignInstance = \App\AutoAssign::getInstanceById((int) $this->template);
- 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 assigning values to variables in if clauses and the like (line '34', column '157'). Open
public function doTask($recordModel)
{
$autoAssignInstance = \App\AutoAssign::getInstanceById((int) $this->template);
if ($autoAssignInstance && $autoAssignInstance->isActive(\App\AutoAssign::MODE_WORKFLOW) && $autoAssignInstance->checkConditionForRecord($recordModel) && $assignedUserId = $autoAssignInstance->getOwner()) {
$fieldModel = $recordModel->getField('assigned_user_id');
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Reference to undeclared property \VTAutoAssign->template
Open
$autoAssignInstance = \App\AutoAssign::getInstanceById((int) $this->template);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class VTAutoAssign extends VTTask
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 11 and the first side effect is on line 9. Open
<?php
- 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
$fieldModel = $recordModel->getField('assigned_user_id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $executeImmediately = 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
$cloneRecordModel->ext = $recordModel->ext;
- 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 214 characters Open
if ($autoAssignInstance && $autoAssignInstance->isActive(\App\AutoAssign::MODE_WORKFLOW) && $autoAssignInstance->checkConditionForRecord($recordModel) && $assignedUserId = $autoAssignInstance->getOwner()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cloneRecordModel->isNew = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cloneRecordModel->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
* Execute task.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cloneRecordModel = \Vtiger_Record_Model::getCleanInstance($recordModel->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var bool */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFieldNames()
- 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
$cloneRecordModel->setData($recordModel->getData());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($autoAssignInstance && $autoAssignInstance->isActive(\App\AutoAssign::MODE_WORKFLOW) && $autoAssignInstance->checkConditionForRecord($recordModel) && $assignedUserId = $autoAssignInstance->getOwner()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$cloneRecordModel->setDataForSave([$fieldModel->getTableName() => [$fieldModel->getColumnName() => $assignedUserId]]);
- 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
$cloneRecordModel->set($fieldModel->getName(), $assignedUserId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function doTask($recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$autoAssignInstance = \App\AutoAssign::getInstanceById((int) $this->template);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cloneRecordModel->setHandlerExceptions(['disableHandlerClasses' => ['Vtiger_Workflow_Handler']]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cloneRecordModel->setDataForSave([$fieldModel->getTableName() => [$fieldModel->getColumnName() => $assignedUserId]]);
- 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
return ['template'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get field names.
- 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
$autoAssignInstance->postProcess($assignedUserId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set($fieldName, $cloneRecordModel->get($fieldName));
- 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
foreach (array_keys($cloneRecordModel->getPreviousValue()) as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks