File Field.php
has 357 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App;
/**
The class Field has an overall complexity of 72 which is very high. The configured complexity threshold is 50. Open
class Field
{
/** @var string[] Help info views. */
const HELP_INFO_VIEWS = ['LBL_EDIT_VIEW' => 'Edit', 'LBL_DETAIL_VIEW' => 'Detail', 'LBL_QUICK_CREATE_VIEW' => 'QuickCreateAjax'];
- Exclude checks
Function getRelatedFieldForModule
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public static function getRelatedFieldForModule($moduleName = false, $forModule = false)
{
$key = 'all';
if (Cache::has('getRelatedFieldForModule', $key)) {
$fields = Cache::get('getRelatedFieldForModule', $key);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getRelatedFieldForModule
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getRelatedFieldForModule($moduleName = false, $forModule = false)
{
$key = 'all';
if (Cache::has('getRelatedFieldForModule', $key)) {
$fields = Cache::get('getRelatedFieldForModule', $key);
Function getFieldPermission
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getFieldsPermissions
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getFieldsPermissions($tabId, $readOnly = true)
{
Log::trace('Entering ' . __METHOD__ . ": $tabId");
if (Cache::has(__METHOD__ . User::getCurrentUserId(), $tabId)) {
$fields = Cache::get(__METHOD__ . User::getCurrentUserId(), $tabId);
Function getFieldsPermissions
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static function getFieldsPermissions($tabId, $readOnly = true)
{
Log::trace('Entering ' . __METHOD__ . ": $tabId");
if (Cache::has(__METHOD__ . User::getCurrentUserId(), $tabId)) {
$fields = Cache::get(__METHOD__ . User::getCurrentUserId(), $tabId);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getColumnPermission
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static function getColumnPermission($tabMix, $columnName, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getFieldPermission
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
Method getColumnPermission
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getColumnPermission($tabMix, $columnName, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
Function checkQuickChangerConditions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function checkQuickChangerConditions(array $field, \Vtiger_Record_Model $recordModel)
{
$return = false;
foreach ($field['conditions'] as $fieldName => $value) {
if ($recordModel->get($fieldName) !== $value) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getFieldInfo
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getFieldInfo($mixed, $module = false)
{
$fieldInfo = false;
if (is_numeric($mixed)) {
if (Cache::has('FieldInfoById', $mixed)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return $fields;
The method getFieldPermission() has an NPath complexity of 288. The configured NPath complexity threshold is 200. Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method getFieldsPermissions() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function getFieldsPermissions($tabId, $readOnly = true)
{
Log::trace('Entering ' . __METHOD__ . ": $tabId");
if (Cache::has(__METHOD__ . User::getCurrentUserId(), $tabId)) {
$fields = Cache::get(__METHOD__ . User::getCurrentUserId(), $tabId);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method getFieldPermission() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method getColumnPermission() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function getColumnPermission($tabMix, $columnName, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method getRelatedFieldForModule() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function getRelatedFieldForModule($moduleName = false, $forModule = false)
{
$key = 'all';
if (Cache::has('getRelatedFieldForModule', $key)) {
$fields = Cache::get('getRelatedFieldForModule', $key);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Reduce the number of returns of this function 5, down to the maximum allowed 3. Open
public static function getRelatedFieldForModule($moduleName = false, $forModule = false)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
public static function getColumnPermission($tabMix, $columnName, $readOnly = true)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed. Open
public static function getFieldsPermissions($tabId, $readOnly = true)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed. Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed. Open
public static function getRelatedFieldForModule($moduleName = false, $forModule = false)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Missing class import via use statement (line '78', column '18'). Open
$query = (new \App\Db\Query())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method getFieldPermission has a boolean flag argument $readOnly, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getFieldsPermissions has a boolean flag argument $readOnly, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getFieldsPermissions($tabId, $readOnly = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '239', column '293'). Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '245', column '297'). Open
$fmrQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_fieldmodulerel.relmodule', 'type' => new \yii\db\Expression($db->quoteValue(1))])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '329', column '22'). Open
$fieldInfo = (new \App\Db\Query())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method getColumnPermission has a boolean flag argument $readOnly, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getColumnPermission($tabMix, $columnName, $readOnly = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getRelatedFieldForModule has a boolean flag argument $moduleName, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getRelatedFieldForModule($moduleName = false, $forModule = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getRelatedFieldForModule has a boolean flag argument $forModule, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getRelatedFieldForModule($moduleName = false, $forModule = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getModuleFieldInfos has a boolean flag argument $returnByColumn, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getModuleFieldInfos($module, bool $returnByColumn = false): array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getFieldInfo has a boolean flag argument $module, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getFieldInfo($mixed, $module = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '305', column '19'). Open
$fields = (new \App\Db\Query())->select(['vtiger_relatedlists_fields.fieldid', 'vtiger_field.fieldname'])->from('vtiger_relatedlists_fields')
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class 'App\Cache' in method 'getFieldsPermissions'. Open
Cache::save(__METHOD__ . User::getCurrentUserId(), $tabId, $fields);
- 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 getFieldsPermissions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query = (new \App\Db\Query())
->select([
'vtiger_field.fieldid',
'vtiger_field.fieldname',
- 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
The method getFieldPermission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
self::$fieldPermissionCacheWrite[$tabId][$fieldMix] = false;
}
- 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\Cache' in method 'getFieldsPermissions'. Open
if (Cache::has(__METHOD__ . User::getCurrentUserId(), $tabId)) {
- 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 getFieldPermission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
self::$fieldPermissionCacheWrite[$tabId][$fieldMix] = $permission;
self::$columnPermissionCacheWrite[$tabId][$field['columnname']] = $permission;
}
- 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\Log' in method 'getFieldPermission'. Open
Log::trace('Entering ' . __METHOD__ . ": $tabId,$fieldMix");
- 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 getFieldPermission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$key = 'fieldname';
}
- 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\User' in method 'getFieldsPermissions'. Open
Cache::save(__METHOD__ . User::getCurrentUserId(), $tabId, $fields);
- 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\User' in method 'getFieldsPermissions'. Open
if (Cache::has(__METHOD__ . User::getCurrentUserId(), $tabId)) {
- 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\User' in method 'getFieldsPermissions'. Open
$fields = Cache::get(__METHOD__ . User::getCurrentUserId(), $tabId);
- 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\Module' in method 'getFieldPermission'. Open
$tabId = Module::getModuleId($tabMix);
- 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\Cache' in method 'getFieldsPermissions'. Open
$fields = Cache::get(__METHOD__ . User::getCurrentUserId(), $tabId);
- 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\Log' in method 'getFieldsPermissions'. Open
Log::trace('Entering ' . __METHOD__ . ": $tabId");
- 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 getColumnPermission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
self::$columnPermissionCacheWrite[$tabId][$columnName] = false;
}
- 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\Cache' in method 'getRelatedFieldForModule'. Open
$fields = Cache::get('getRelatedFieldForModule', $key);
- 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 getFieldInfo uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldsInfo = self::getModuleFieldInfos($module);
if ($fieldsInfo && isset($fieldsInfo[$mixed])) {
$fieldInfo = $fieldsInfo[$mixed];
Cache::save('FieldInfoById', $fieldInfo['fieldid'], $fieldInfo, Cache::LONG);
- 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\Cache' in method 'getModuleFieldInfos'. Open
Cache::save('ModuleFieldInfosByColumn', $module, $fieldInfoByColumn);
- 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\Cache' in method 'getFieldsTypeFromUIType'. Open
Cache::save('getFieldsTypeFromUIType', '', $fieldTypeMapping, Cache::LONG);
- 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 'getCustomListForDefaultValue'. Open
'accountLoggedContact' => \App\Language::translate('LBL_ACCOUNT_LOGGED_CONTACT', 'Settings:LayoutEditor'),
- 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 'getCustomListForDefaultValue'. Open
'loggedContact' => \App\Language::translate('LBL_LOGGED_CONTACT', 'Settings:LayoutEditor'),
- 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 getRelatedFieldForModule uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$db = Db::getInstance();
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
->from('vtiger_field')
->innerJoin('vtiger_tab', 'vtiger_field.tabid = vtiger_tab.tabid')
- 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\Module' in method 'getModuleFieldInfos'. Open
$module = Module::getModuleName($module);
- 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\ModuleHierarchy' in method 'getRelatedFieldForModule'. Open
foreach (ModuleHierarchy::getModulesByUitype($row['uitype']) as $module => $value) {
- 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 'getQuickChangerFields'. Open
$row['values'] = Json::decode($row['values']);
- 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\Cache' in method 'getFieldsFromRelation'. Open
Cache::save('getFieldsFromRelation', $relationId, $fields, Cache::LONG);
- 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\Cache' in method 'getQuickChangerFields'. Open
Cache::save('getQuickChangerFields', $tabId, $rows, Cache::LONG);
- 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\Cache' in method 'getFieldInfo'. Open
return Cache::get('FieldInfoById', $mixed);
- 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\Cache' in method 'getModuleFieldInfos'. Open
return Cache::get($cacheName, $module);
- 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\Module' in method 'getModuleFieldInfos'. Open
->where(['tabid' => Module::getModuleId($module)])
- 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\Cache' in method 'getFieldsFromRelation'. Open
$fields = Cache::get('getFieldsFromRelation', $relationId);
- 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\Cache' in method 'getFieldInfo'. Open
Cache::save('FieldInfoById', $fieldInfo['fieldid'], $fieldInfo, Cache::LONG);
- 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\Module' in method 'getColumnPermission'. Open
$tabId = Module::getModuleId($tabMix);
- 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\Cache' in method 'getRelatedFieldForModule'. Open
if (Cache::has('getRelatedFieldForModule', $key)) {
- 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\Db' in method 'getRelatedFieldForModule'. Open
$db = Db::getInstance();
- 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\Cache' in method 'getFieldInfo'. Open
Cache::save('FieldInfoById', $mixed, $fieldInfo, Cache::LONG);
- 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\Cache' in method 'getModuleFieldInfos'. Open
Cache::save($cacheName, $module, $fieldInfoByName);
- 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 getFieldsFromRelation uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fields = (new \App\Db\Query())->select(['vtiger_relatedlists_fields.fieldid', 'vtiger_field.fieldname'])->from('vtiger_relatedlists_fields')
->innerJoin('vtiger_field', 'vtiger_field.fieldid = vtiger_relatedlists_fields.fieldid')
->where(['relation_id' => $relationId, 'vtiger_field.presence' => [0, 2]])->orderBy(['vtiger_relatedlists_fields.relation_id' => SORT_ASC, 'vtiger_relatedlists_fields.sequence' => SORT_ASC])
->createCommand()->queryAllByGroup();
- 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\Cache' in method 'getFieldInfo'. Open
if (Cache::has('FieldInfoById', $mixed)) {
- 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\Log' in method 'getColumnPermission'. Open
Log::trace('Entering ' . __METHOD__ . ": $tabId,$columnName");
- 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\Cache' in method 'getFieldsFromRelation'. Open
if (Cache::has('getFieldsFromRelation', $relationId)) {
- 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\Cache' in method 'getModuleFieldInfos'. Open
if (!Cache::has($cacheName, $module)) {
- 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\Cache' in method 'getQuickChangerFields'. Open
if (Cache::has('getQuickChangerFields', $tabId)) {
- 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 'getQuickChangerFields'. Open
$row['conditions'] = Json::decode($row['conditions']);
- 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 'getCustomListForDefaultValue'. Open
'accountOnContact' => \App\Language::translate('LBL_ACCOUNT_ON_CONTACT', 'Settings:LayoutEditor'),
- 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 getColumnPermission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
self::$columnPermissionCacheWrite[$tabId][$columnName] = $permission;
self::$fieldPermissionCacheWrite[$tabId][$field['fieldname']] = $permission;
}
- 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\Cache' in method 'getRelatedFieldForModule'. Open
Cache::save('getRelatedFieldForModule', $key, $fields, Cache::LONG);
- 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\Cache' in method 'getModuleFieldInfos'. Open
return Cache::get('ModuleFieldInfosByColumn', $module);
- 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\Cache' in method 'getFieldsTypeFromUIType'. Open
if (Cache::has('getFieldsTypeFromUIType', '')) {
- 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\Cache' in method 'getQuickChangerFields'. Open
return Cache::get('getQuickChangerFields', $tabId);
- 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\Cache' in method 'getFieldsTypeFromUIType'. Open
return Cache::get('getFieldsTypeFromUIType', '');
- 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 "maximumlength" 8 times. Open
'uitype' => 53, 'typeofdata' => 'V~M', 'maximumlength' => 65535,
- 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 "fieldname" 8 times. Open
if (isset($fields[$row['fieldname']])) {
- 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 "vtiger_tab.name" 3 times. Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- 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 "columntype" 3 times. Open
'uitype' => 120, 'typeofdata' => 'V~O', 'columntype' => 'int(11)', 'maximumlength' => 65535,
- 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 "getFieldsFromRelation" 3 times. Open
if (Cache::has('getFieldsFromRelation', $relationId)) {
- 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 "vtiger_field.fieldlabel" 3 times. Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- 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 "vtiger_field.fieldname" 5 times. Open
'vtiger_field.fieldname',
- 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 "vtiger_field.tabid" 4 times. Open
'vtiger_field.tabid' => (int) $tabId,
- 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 "displaytype" 4 times. Open
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- 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 "values" 3 times. Open
$row['values'] = Json::decode($row['values']);
- 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 "getRelatedFieldForModule" 3 times. Open
if (Cache::has('getRelatedFieldForModule', $key)) {
- 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 "modifiedtime" 3 times. Open
'modifiedtime' => [
- 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 "validationConditions" 8 times. Open
'validationConditions' => ['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.
Define a constant instead of duplicating this literal "private" 3 times. Open
'private' => [
- 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 "vtiger_crmentity" 7 times. Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- 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 "vtiger_field.tabid = vtiger_tab.tabid" 3 times. Open
->innerJoin('vtiger_tab', 'vtiger_field.tabid = vtiger_tab.tabid')
- 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 "modifiedby" 3 times. Open
'modifiedby' => [
- 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 "Entering " 3 times. Open
Log::trace('Entering ' . __METHOD__ . ": $tabId");
- 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 "vtiger_field.columnname" 4 times. Open
'vtiger_field.columnname',
- 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 "visible" 6 times. Open
$row['visible'] = $old['visible'] > 0 ? $row['visible'] : $old['visible'];
- 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 "table" 7 times. Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- 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 "conditions" 3 times. Open
$row['conditions'] = Json::decode($row['conditions']);
- 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 "vtiger_tab" 3 times. Open
->innerJoin('vtiger_tab', 'vtiger_field.tabid = vtiger_tab.tabid')
- 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 "vtiger_field.tablename" 3 times. Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- 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 "vtiger_field.uitype" 4 times. Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- 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 "vtiger_tab.presence" 3 times. Open
->where(['vtiger_tab.presence' => 0]);
- 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 "getQuickChangerFields" 3 times. Open
if (Cache::has('getQuickChangerFields', $tabId)) {
- 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 "columnname" 4 times. Open
self::$columnPermissionCacheRead[$tabId][$field['columnname']] = $permission;
- 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 "createdtime" 3 times. Open
'createdtime' => [
- 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 "readonly" 5 times. Open
$row['readonly'] = $old['readonly'] > 0 ? $row['readonly'] : $old['readonly'];
- 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 "shownerid" 3 times. Open
'shownerid' => [
- 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 "Settings:LayoutEditor" 3 times. Open
'loggedContact' => \App\Language::translate('LBL_LOGGED_CONTACT', 'Settings:LayoutEditor'),
- 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 "share_externally" 3 times. Open
'share_externally' => [
- 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 "label" 8 times. Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- 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 "column" 9 times. Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- 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 "typeofdata" 8 times. Open
'uitype' => 53, 'typeofdata' => 'V~M', 'maximumlength' => 65535,
- 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 "vtiger_field.fieldid" 5 times. Open
'vtiger_field.fieldid',
- 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 "vtiger_field" 7 times. Open
->from('vtiger_field')
- 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 "FieldInfoById" 4 times. Open
if (Cache::has('FieldInfoById', $mixed)) {
- 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 "relmod" 5 times. Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- 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 "uitype" 11 times. Open
'uitype' => 53, 'typeofdata' => 'V~M', 'maximumlength' => 65535,
- 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 "getFieldsTypeFromUIType" 3 times. Open
if (Cache::has('getFieldsTypeFromUIType', '')) {
- 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.
Avoid unused local variables such as '$value'. Open
foreach (ModuleHierarchy::getModulesByUitype($row['uitype']) as $module => $value) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Call to undeclared method \App\Db\Query::select
Open
$fmrQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_fieldmodulerel.relmodule', 'type' => new \yii\db\Expression($db->quoteValue(1))])
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
$fields = Cache::get('getFieldsFromRelation', $relationId);
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
$fields = Cache::get(__METHOD__ . User::getCurrentUserId(), $tabId);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
Log::trace('Entering ' . __METHOD__ . ": $tabId,$columnName");
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
if (Cache::has('getFieldsFromRelation', $relationId)) {
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
if (Cache::has('getQuickChangerFields', $tabId)) {
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
Cache::save(__METHOD__ . User::getCurrentUserId(), $tabId, $fields);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new Db\Query())->from('s_#__record_quick_changer')->where(['tabid' => $tabId])->createCommand()->query();
- Exclude checks
Returning type bool
but checkQuickChangerConditions()
is declared to return void
Open
return $return;
- Exclude checks
Default value for \App\type
$readOnly
can't be true
Open
public static function getFieldsPermissions($tabId, $readOnly = true)
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$fieldInfo = (new \App\Db\Query())
- Exclude checks
Parameter $readOnly
has undeclared type \App\type
Open
public static function getFieldsPermissions($tabId, $readOnly = true)
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$fields = (new \App\Db\Query())->select(['vtiger_relatedlists_fields.fieldid', 'vtiger_field.fieldname'])->from('vtiger_relatedlists_fields')
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name'])
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$fieldTypeMapping = (new Db\Query())->from('vtiger_ws_fieldtype')->indexBy('uitype')->all();
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
return Cache::get('getQuickChangerFields', $tabId);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
Log::trace('Entering ' . __METHOD__ . ": $tabId");
- Exclude checks
Call to undeclared method \App\Db::quoteValue
Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
Cache::save(__METHOD__ . User::getCurrentUserId(), $tabId, $fields);
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
Cache::save('getQuickChangerFields', $tabId, $rows, Cache::LONG);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
Log::trace('Entering ' . __METHOD__ . ": $tabId,$fieldMix");
- Exclude checks
Call to undeclared method \App\Db::quoteValue
Open
$fmrQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_fieldmodulerel.relmodule', 'type' => new \yii\db\Expression($db->quoteValue(1))])
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
if (Cache::has(__METHOD__ . User::getCurrentUserId(), $tabId)) {
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$profileList = \App\User::getCurrentUserModel()->getProfiles();
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
Cache::save('getFieldsFromRelation', $relationId, $fields, Cache::LONG);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
if (Cache::has(__METHOD__ . User::getCurrentUserId(), $tabId)) {
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$fields = Cache::get(__METHOD__ . User::getCurrentUserId(), $tabId);
- Exclude checks
Default value for int|string
$module
can't be false
Open
public static function getFieldInfo($mixed, $module = false)
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$fmrQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_fieldmodulerel.relmodule', 'type' => new \yii\db\Expression($db->quoteValue(1))])
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new Db\Query())
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($field[$key] === $fieldMix) {
$permission = !($field['visible']);
if ($readOnly) {
self::$fieldPermissionCacheRead[$tabId][$fieldMix] = $permission;
self::$columnPermissionCacheRead[$tabId][$field['columnname']] = $permission;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 105.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($field['columnname'] === $columnName) {
$permission = !($field['visible']);
if ($readOnly) {
self::$columnPermissionCacheRead[$tabId][$columnName] = $permission;
self::$fieldPermissionCacheRead[$tabId][$field['fieldname']] = $permission;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 105.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid excessively long variable names like $columnPermissionCacheRead. Keep variable name length under 20. Open
private static $columnPermissionCacheRead = [];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $fieldPermissionCacheRead. Keep variable name length under 20. Open
private static $fieldPermissionCacheRead = [];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $fieldPermissionCacheWrite. Keep variable name length under 20. Open
private static $fieldPermissionCacheWrite = [];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $columnPermissionCacheWrite. Keep variable name length under 20. Open
private static $columnPermissionCacheWrite = [];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used for alignment; tabs are not allowed Open
'validationConditions' => ['name'],
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'modifiedtime', 'column' => 'modifiedtime', 'label' => 'Modified Time', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'private' => [
- 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
* @return array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'created_user_id', 'column' => 'smcreatorid', 'label' => 'Created By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'private', 'column' => 'private', 'label' => 'FL_IS_PRIVATE', 'table' => 'vtiger_crmentity',
- 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
'validationConditions' => ['name'],
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'createdtime', 'column' => 'createdtime', 'label' => 'Created Time', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'modifiedtime', 'column' => 'modifiedtime', 'label' => 'Modified Time', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- 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
'name' => 'modifiedby', 'column' => 'modifiedby', 'label' => 'Last Modified By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- 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
'shownerid' => [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 120, 'typeofdata' => 'V~O', 'columntype' => 'int(11)', 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'modifiedtime', 'column' => 'modifiedtime', 'label' => 'Modified Time', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'private', 'column' => 'private', 'label' => 'FL_IS_PRIVATE', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'private', 'column' => 'private', 'label' => 'FL_IS_PRIVATE', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'share_externally', 'column' => 'share_externally', 'label' => 'FL_SHARE_EXTERNALLY', 'defaultvalue' => 0, 'fieldparams' => 1,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'modifiedtime', 'column' => 'modifiedtime', 'label' => 'Modified Time', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'modifiedby', 'column' => 'modifiedby', 'label' => 'Last Modified By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 318, 'typeofdata' => 'C~O', 'columntype' => 'tinyint(1)', 'maximumlength' => '-128,127',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int $tabId Module ID
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'createdtime', 'column' => 'createdtime', 'label' => 'Created Time', 'table' => 'vtiger_crmentity',
- 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
'validationConditions' => ['name'],
- 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
Log::trace('Entering ' . __METHOD__ . ": $tabId");
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_field.fieldid',
- 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
return $fields;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param bool $readOnly Read/preview only fields
- 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
$key = 'fieldid';
- 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
$tabId = Module::getModuleId($tabMix);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$columnPermissionCacheRead[$tabId][$columnName] = $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$columnPermissionCacheWrite[$tabId][$columnName] = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 53, 'typeofdata' => 'V~M', 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'shownerid', 'column' => 'shownerid', 'label' => 'Share with users', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'share_externally', 'column' => 'share_externally', 'label' => 'FL_SHARE_EXTERNALLY', 'defaultvalue' => 0, 'fieldparams' => 1,
- 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
$fields = [];
- 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
* @param bool|string $moduleName
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'createdtime' => [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'created_user_id' => [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'shownerid', 'column' => 'shownerid', 'label' => 'Share with users', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'share_externally', 'column' => 'share_externally', 'label' => 'FL_SHARE_EXTERNALLY', 'defaultvalue' => 0, 'fieldparams' => 1,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 318, 'typeofdata' => 'C~O', 'columntype' => 'tinyint(1)', 'maximumlength' => '-128,127',
- 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
'uitype' => 53, 'typeofdata' => 'V~M', 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'modifiedtime' => [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'validationConditions' => ['name'],
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'modifiedby', 'column' => 'modifiedby', 'label' => 'Last Modified By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 120, 'typeofdata' => 'V~O', 'columntype' => 'int(11)', 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'share_externally', 'column' => 'share_externally', 'label' => 'FL_SHARE_EXTERNALLY', 'defaultvalue' => 0, 'fieldparams' => 1,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Function gets the list of fields that the user has permissions to.
- 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
'vtiger_field.columnname',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_field.tabid' => (int) $tabId,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int|string $tabMix Module ID or module name
- 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
$tabId = Module::getModuleId($tabMix);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$fieldPermissionCacheRead[$tabId][$fieldMix] = $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getColumnPermission($tabMix, $columnName, $readOnly = true)
- 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
* @param bool|string $forModule
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'createdtime', 'column' => 'createdtime', 'label' => 'Created Time', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 56, 'typeofdata' => 'C~O', 'columntype' => 'int(11)', 'maximumlength' => '-128,127', 'presence' => 2, 'generatedtype' => 2,
- 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
'share_externally' => [
- 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
'modifiedby' => [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'modifiedby', 'column' => 'modifiedby', 'label' => 'Last Modified By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'shownerid', 'column' => 'shownerid', 'label' => 'Share with users', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'private', 'column' => 'private', 'label' => 'FL_IS_PRIVATE', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$query = (new \App\Db\Query())
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->where([
- 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
return self::$fieldPermissionCacheWrite[$tabId][$fieldMix];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($readOnly) {
- 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
self::$fieldPermissionCacheRead[$tabId][$fieldMix] = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$fieldPermissionCacheRead[$tabId][$field['fieldname']] = $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($readOnly) {
- 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
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'validationConditions' => ['column'],
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'created_user_id', 'column' => 'smcreatorid', 'label' => 'Created By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'validationConditions' => ['uitype', 'fieldparams'],
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param type $readOnly Read/preview only fields
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getFieldsPermissions($tabId, $readOnly = true)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_field.presence' => [0, 2],
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $fields;
- 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
$fields = static::getFieldsPermissions($tabId, $readOnly);
- 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
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get related field for module.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 53, 'typeofdata' => 'V~M', 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 70, 'typeofdata' => 'DT~O', 'displaytype' => 2, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'created_user_id', 'column' => 'smcreatorid', 'label' => 'Created By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'validationConditions' => ['name'],
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 56, 'typeofdata' => 'C~O', 'columntype' => 'int(11)', 'maximumlength' => '-128,127', 'presence' => 2, 'generatedtype' => 2,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 56, 'typeofdata' => 'C~O', 'columntype' => 'int(11)', 'maximumlength' => '-128,127', 'presence' => 2, 'generatedtype' => 2,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'share_externally', 'column' => 'share_externally', 'label' => 'FL_SHARE_EXTERNALLY', 'defaultvalue' => 0, 'fieldparams' => 1,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 318, 'typeofdata' => 'C~O', 'columntype' => 'tinyint(1)', 'maximumlength' => '-128,127',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_field.fieldname',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private static $fieldPermissionCacheRead = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return bool
- 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
if (!is_numeric($tabMix)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'createdtime', 'column' => 'createdtime', 'label' => 'Created Time', 'table' => 'vtiger_crmentity',
- 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
'name' => 'created_user_id', 'column' => 'smcreatorid', 'label' => 'Created By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'name' => 'shownerid', 'column' => 'shownerid', 'label' => 'Share with users', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'uitype' => 120, 'typeofdata' => 'V~O', 'columntype' => 'int(11)', 'maximumlength' => 65535,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($profileList) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader = $query->distinct()->createCommand()->query();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fields[$row['fieldname']] = $row;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Cache::save(__METHOD__ . User::getCurrentUserId(), $tabId, $fields);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($fields as &$field) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Log::trace('Entering ' . __METHOD__ . ": $tabId,$columnName");
- 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
foreach ($fields as &$field) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($field['columnname'] === $columnName) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$columnPermissionCacheWrite[$tabId][$columnName] = $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$fieldPermissionCacheWrite[$tabId][$field['fieldname']] = $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($fields as $key => $field) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int|string $fieldMix Field ID or field name
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$tabId = $tabMix;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$fieldPermissionCacheWrite[$tabId][$fieldMix] = $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private static $columnPermissionCacheWrite = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return self::$columnPermissionCacheRead[$tabId][$columnName];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($readOnly) {
- 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
->from('vtiger_field')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->innerJoin('vtiger_profile2field', 'vtiger_profile2field.fieldid = vtiger_field.fieldid')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
while ($row = $dataReader->read()) {
- 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
$key = 'fieldname';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private static $columnPermissionCacheRead = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param bool $readOnly Read/preview only fields
- 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
return $permission;
- 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
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($field['readonly']) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (is_numeric($fieldMix)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldMix = (int) $fieldMix;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$permission = !($field['visible']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$fieldPermissionCacheWrite[$tabId][$fieldMix] = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$columnPermissionCacheRead[$tabId][$columnName] = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->select([
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$query->andWhere(['vtiger_profile2field.profileid' => $profileList]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$row['readonly'] = $old['readonly'] > 0 ? $row['readonly'] : $old['readonly'];
- 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 (!is_numeric($tabMix)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($field[$key] === $fieldMix) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$tabId = $tabMix;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_field.visible' => 0,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (isset($fields[$row['fieldname']])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($readOnly) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Function checks field permissions by field name or field id.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return self::$fieldPermissionCacheRead[$tabId][$fieldMix];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$columnPermissionCacheRead[$tabId][$field['columnname']] = $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int|string $tabMix Module ID or module name
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($readOnly && isset(self::$columnPermissionCacheRead[$tabId][$columnName])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$permission = !($field['visible']);
- 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
if ($readOnly && isset(self::$fieldPermissionCacheRead[$tabId][$fieldMix])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($readOnly) {
- 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
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fields = Cache::get(__METHOD__ . User::getCurrentUserId(), $tabId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_profile2field.readonly',
- 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
Log::trace('Entering ' . __METHOD__ . ": $tabId,$fieldMix");
- 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
if (!$readOnly && isset(self::$columnPermissionCacheWrite[$tabId][$columnName])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return self::$columnPermissionCacheWrite[$tabId][$columnName];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return false;
- 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
$row['visible'] = $old['visible'] > 0 ? $row['visible'] : $old['visible'];
- 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 (Cache::has(__METHOD__ . User::getCurrentUserId(), $tabId)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
unset($fields[$key]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private static $fieldPermissionCacheWrite = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$readOnly && isset(self::$fieldPermissionCacheWrite[$tabId][$fieldMix])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_profile2field.visible',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
self::$columnPermissionCacheWrite[$tabId][$field['columnname']] = $permission;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $columnName Field ID or field name
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_profile2field.visible' => 0,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fields = static::getFieldsPermissions($tabId, $readOnly);
- 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
$profileList = \App\User::getCurrentUserModel()->getProfiles();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$old = $fields[$row['fieldname']];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($forModule) {
- 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
$rfields = [];
- 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
* Function checks field permissions by column name.
- 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
* @return bool
- 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
* Function to gets module field info.
- 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
$fields = Cache::get('getRelatedFieldForModule', $key);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->from('vtiger_field')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach (ModuleHierarchy::getModulesByUitype($row['uitype']) as $module => $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $fields[$moduleName][$forModule] ?? [];
- 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
return [];
- 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
->createCommand()->queryAllByGroup();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getFieldInfo($mixed, $module = false)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Function get module field infos.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return Cache::get($cacheName, $module);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->from('vtiger_field')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fields = [];
- 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
* @param int $relationId
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Cache::save('FieldInfoById', $mixed, $fieldInfo, Cache::LONG);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getModuleFieldInfos($module, bool $returnByColumn = false): array
- 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
$cacheName = 'ModuleFieldInfosByName';
- 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
return $rfields;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return array|null
- 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
$fieldsInfo = self::getModuleFieldInfos($module);
- 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
$fields[$row['name']][$row['relmod']] = $row;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$row['relmod'] = $module;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($forModule) {
- 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
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getRelatedFieldForModule($moduleName = false, $forModule = false)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->where(['vtiger_tab.presence' => 0]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$query = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name'])
- 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
->createCommand()->query();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$row['type'] = 3;
- 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
$rfields[$moduleName] = $forModules[$forModule];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->where(['relation_id' => $relationId, 'vtiger_field.presence' => [0, 2]])->orderBy(['vtiger_relatedlists_fields.relation_id' => SORT_ASC, 'vtiger_relatedlists_fields.sequence' => SORT_ASC])
- 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
->innerJoin('vtiger_ws_referencetype', 'vtiger_ws_fieldtype.fieldtypeid = vtiger_ws_referencetype.fieldtypeid')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (is_numeric($mixed)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return Cache::get('FieldInfoById', $mixed);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->from('vtiger_field')
- 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
* @return array
- 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
* Function get module field infos by presence.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->leftJoin('s_#__fields_anonymization', 'vtiger_field.fieldid = s_#__fields_anonymization.field_id')
- 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 (is_numeric($module)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Cache::save('ModuleFieldInfosByColumn', $module, $fieldInfoByColumn);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->innerJoin('vtiger_ws_fieldtype', 'vtiger_field.uitype = vtiger_ws_fieldtype.uitype')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fields[$row['name']][$row['relmod']] = $row;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $fields;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (Cache::has('getFieldsFromRelation', $relationId)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fields = Cache::get('getFieldsFromRelation', $relationId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldInfo = $fieldsInfo[$mixed];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return Cache::get('ModuleFieldInfosByColumn', $module);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->innerJoin('vtiger_fieldmodulerel', 'vtiger_field.fieldid = vtiger_fieldmodulerel.fieldid')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader = $wsQuery->union($fmrQuery)->createCommand()->query();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->where(['vtiger_tab.presence' => 0, 'vtiger_field.uitype' => [64, 65, 66, 67, 68]]);
- 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
* Get fields from relation by relation Id.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader = (new Db\Query())
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getModuleFieldInfosByPresence($module, array $presence = ['0', '2']): array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$moduleFields[$fieldInfo['fieldname']] = $fieldInfo;
- 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
$row['conditions'] = Json::decode($row['conditions']);
- 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
* @return void
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$key = 'all';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->innerJoin('vtiger_tab', 'vtiger_field.tabid = vtiger_tab.tabid')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (isset($fields[$moduleName])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string[]
- 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
->from('vtiger_field')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldInfoByName = $fieldInfoByColumn = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (Cache::has('getRelatedFieldForModule', $key)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->innerJoin('vtiger_tab', 'vtiger_field.tabid = vtiger_tab.tabid')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Cache::save('getRelatedFieldForModule', $key, $fields, Cache::LONG);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $fields[$moduleName];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (isset($forModules[$forModule])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fields = (new \App\Db\Query())->select(['vtiger_relatedlists_fields.fieldid', 'vtiger_field.fieldname'])->from('vtiger_relatedlists_fields')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->innerJoin('vtiger_field', 'vtiger_field.fieldid = vtiger_relatedlists_fields.fieldid')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (Cache::has('FieldInfoById', $mixed)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!Cache::has($cacheName, $module)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->leftJoin('s_#__fields_anonymization', 'vtiger_field.fieldid = s_#__fields_anonymization.field_id')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->where(['tabid' => Module::getModuleId($module)])
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($returnByColumn) {
- 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 (\in_array($fieldInfo['presence'], $presence)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get fields type from uitype.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getQuickChangerFields(int $tabId): array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $return;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'loggedContact' => \App\Language::translate('LBL_LOGGED_CONTACT', 'Settings:LayoutEditor'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'accountLoggedContact' => \App\Language::translate('LBL_ACCOUNT_LOGGED_CONTACT', 'Settings:LayoutEditor'),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getFieldsFromRelation($relationId)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($relationId)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->where(['vtiger_field.fieldid' => $mixed])->one();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Cache::save('FieldInfoById', $fieldInfo['fieldid'], $fieldInfo, Cache::LONG);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $fieldInfo;
- 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
$fieldTypeMapping = (new Db\Query())->from('vtiger_ws_fieldtype')->indexBy('uitype')->all();
- 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
$rows = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
while ($row = $dataReader->read()) {
- 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
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fmrQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_fieldmodulerel.relmodule', 'type' => new \yii\db\Expression($db->quoteValue(1))])
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->where(['vtiger_tab.presence' => 0]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->innerJoin('vtiger_tab', 'vtiger_field.tabid = vtiger_tab.tabid')
- 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
Cache::save('getFieldsFromRelation', $relationId, $fields, Cache::LONG);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $fields;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($fieldsInfo && isset($fieldsInfo[$mixed])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int|string $module
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param bool $returnByColumn
- 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
$module = Module::getModuleName($module);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldInfoByColumn[$row['columnname']] = $row;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $moduleFields;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return array
- 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
* @return array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $rows;
- 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
$status = 1;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$db = Db::getInstance();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($fields as $moduleName => $forModules) {
- 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
* @param int|string $mixed
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param int|string $module
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- 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
Cache::save('getFieldsTypeFromUIType', '', $fieldTypeMapping, Cache::LONG);
- 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
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param array $presence
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $fieldTypeMapping;
- 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
'accountOnContact' => \App\Language::translate('LBL_ACCOUNT_ON_CONTACT', 'Settings:LayoutEditor'),
- 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
foreach ($fieldsInfo as $fieldInfo) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Check quick changer conditions.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function checkQuickChangerConditions(array $field, \Vtiger_Record_Model $recordModel)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \Vtiger_Field_Model $fieldModel
- 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
->from('vtiger_field')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($moduleName) {
- 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
$fieldInfo = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldInfo = (new \App\Db\Query())
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldInfoByName[$row['fieldname']] = $row;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Cache::save($cacheName, $module, $fieldInfoByName);
- 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
* @return array
- 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 (Cache::has('getQuickChangerFields', $tabId)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$return = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($field['values'] as $fieldName => $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string[]
- 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
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$row['values'] = Json::decode($row['values']);
- 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
* @param int|string $module
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getFieldsTypeFromUIType()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader = (new Db\Query())->from('s_#__record_quick_changer')->where(['tabid' => $tabId])->createCommand()->query();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param array $field
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$return = true;
- 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
return [
- 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
* @param int $tabId
- 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
if (!isset($status)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$moduleFields = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get quick changer fields.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (isset($fields[$fieldName]) && $fields[$fieldName]->isEditable()) {
- 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
$fieldsInfo = self::getModuleFieldInfos($module);
- 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 (Cache::has('getFieldsTypeFromUIType', '')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return Cache::get('getFieldsTypeFromUIType', '');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($recordModel->get($fieldName) !== $value) {
- 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
$rows[$row['id']] = $row;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($field['conditions'] as $fieldName => $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getCustomListForDefaultValue(\Vtiger_Field_Model $fieldModel): array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return Cache::get('getQuickChangerFields', $tabId);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Cache::save('getQuickChangerFields', $tabId, $rows, Cache::LONG);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fields = $recordModel->getModule()->getFields();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get a list of custom default values for a given field type in the WebservicePremium API.
- 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 ($fieldModel->isReferenceField()) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
];
- Exclude checks
The 'getFieldPermission()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public static function getFieldPermission($tabMix, $fieldMix, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
The 'getColumnPermission()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public static function getColumnPermission($tabMix, $columnName, $readOnly = true)
{
$tabId = $tabMix;
if (!is_numeric($tabMix)) {
$tabId = Module::getModuleId($tabMix);
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
Line exceeds 120 characters; contains 126 characters Open
'name' => 'modifiedby', 'column' => 'modifiedby', 'label' => 'Last Modified By', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string[] Help info views. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array System fields */
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const HELP_INFO_VIEWS = ['LBL_EDIT_VIEW' => 'Edit', 'LBL_DETAIL_VIEW' => 'Detail', 'LBL_QUICK_CREATE_VIEW' => 'QuickCreateAjax'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => 'assigned_user_id', 'column' => 'smownerid', 'label' => 'Assigned To', 'table' => 'vtiger_crmentity',
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
'name' => 'created_user_id', 'column' => 'smcreatorid', 'label' => 'Created By', 'table' => 'vtiger_crmentity',
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const SYSTEM_FIELDS = [
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
'uitype' => 56, 'typeofdata' => 'C~O', 'columntype' => 'int(11)', 'maximumlength' => '-128,127', 'presence' => 2, 'generatedtype' => 2,
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
const HELP_INFO_VIEWS = ['LBL_EDIT_VIEW' => 'Edit', 'LBL_DETAIL_VIEW' => 'Detail', 'LBL_QUICK_CREATE_VIEW' => 'QuickCreateAjax'];
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
'name' => 'share_externally', 'column' => 'share_externally', 'label' => 'FL_SHARE_EXTERNALLY', 'defaultvalue' => 0, 'fieldparams' => 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'assigned_user_id' => [
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
'name' => 'createdtime', 'column' => 'createdtime', 'label' => 'Created Time', 'table' => 'vtiger_crmentity',
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
'uitype' => 52, 'typeofdata' => 'V~O', 'displaytype' => 2, 'quickcreate' => 3, 'masseditable' => 0, 'maximumlength' => 65535,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'validationConditions' => ['name'],
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
'name' => 'modifiedtime', 'column' => 'modifiedtime', 'label' => 'Modified Time', 'table' => 'vtiger_crmentity',
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
'name' => 'shownerid', 'column' => 'shownerid', 'label' => 'Share with users', 'table' => 'vtiger_crmentity',
- Exclude checks
Line exceeds 120 characters; contains 241 characters Open
$query = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name'])
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
$fields = (new \App\Db\Query())->select(['vtiger_relatedlists_fields.fieldid', 'vtiger_field.fieldname'])->from('vtiger_relatedlists_fields')
- Exclude checks
Line exceeds 120 characters; contains 206 characters Open
->where(['relation_id' => $relationId, 'vtiger_field.presence' => [0, 2]])->orderBy(['vtiger_relatedlists_fields.relation_id' => SORT_ASC, 'vtiger_relatedlists_fields.sequence' => SORT_ASC])
- Exclude checks
Line exceeds 120 characters; contains 345 characters Open
$fmrQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_fieldmodulerel.relmodule', 'type' => new \yii\db\Expression($db->quoteValue(1))])
- Exclude checks
Line exceeds 120 characters; contains 341 characters Open
$wsQuery = (new Db\Query())->select(['vtiger_field.fieldid', 'vtiger_field.uitype', 'vtiger_field.tabid', 'vtiger_field.columnname', 'vtiger_field.fieldname', 'vtiger_field.tablename', 'vtiger_field.fieldlabel', 'vtiger_tab.name', 'relmod' => 'vtiger_ws_referencetype.type', 'type' => new \yii\db\Expression($db->quoteValue(2))])
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
->innerJoin('vtiger_ws_referencetype', 'vtiger_ws_fieldtype.fieldtypeid = vtiger_ws_referencetype.fieldtypeid')
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$dataReader = (new Db\Query())->from('s_#__record_quick_changer')->where(['tabid' => $tabId])->createCommand()->query();
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
'accountLoggedContact' => \App\Language::translate('LBL_ACCOUNT_LOGGED_CONTACT', 'Settings:LayoutEditor'),
- Exclude checks