Avoid using static access to class '\App\AutoAssign' in method 'entityBeforeSave'. Open
if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->getOwner())) {
- 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 '26', column '33'). Open
public function entityBeforeSave(App\EventHandler $eventHandler): void
{
$recordModel = $eventHandler->getRecordModel();
if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->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
Avoid assigning values to variables in if clauses and the like (line '26', column '142'). Open
public function entityBeforeSave(App\EventHandler $eventHandler): void
{
$recordModel = $eventHandler->getRecordModel();
if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_AutoAssign_Handler
- Exclude checks
The class Vtiger_AutoAssign_Handler is not named in CamelCase. Open
class Vtiger_AutoAssign_Handler
{
/**
* EntityBeforeSave function.
*
- 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 for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordModel->setDataForSave([$fieldModel->getTableName() => [$fieldModel->getColumnName() => $assignedUserId]]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordModel->set($fieldModel->getName(), $assignedUserId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->getOwner())) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldModel = $recordModel->getField('assigned_user_id');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param App\EventHandler $eventHandler
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* EntityBeforeSave function.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @package Handler
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$autoAssignModel->postProcess($assignedUserId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function entityBeforeSave(App\EventHandler $eventHandler): void
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordModel = $eventHandler->getRecordModel();
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$recordModel->setDataForSave([$fieldModel->getTableName() => [$fieldModel->getColumnName() => $assignedUserId]]);
- Exclude checks
Line exceeds 120 characters; contains 197 characters Open
if ($recordModel->isNew() && ($autoAssignModel = \App\AutoAssign::getAutoAssignForRecord($recordModel, \App\AutoAssign::MODE_HANDLER)) && ($assignedUserId = $autoAssignModel->getOwner())) {
- Exclude checks
Class name "Vtiger_AutoAssign_Handler" is not in camel caps format Open
class Vtiger_AutoAssign_Handler
- Exclude checks