Function retrieveEntityInfo
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function retrieveEntityInfo(int $record, string $module)
{
\App\Log::trace("Entering into retrieveEntityInfo($record, $module) method.");
if ('' == $record) {
\App\Log::error('record is empty. returning null');
- 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 retrieveEntityInfo
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function retrieveEntityInfo(int $record, string $module)
{
\App\Log::trace("Entering into retrieveEntityInfo($record, $module) method.");
if ('' == $record) {
\App\Log::error('record is empty. returning null');
The class Users has 26 fields. Consider redesigning Users to keep the number of fields under 15. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Function getActiveAdminId
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function getActiveAdminId()
{
$cache = Vtiger_Cache::getInstance();
if ($cache->getAdminUserId()) {
return $cache->getAdminUserId();
- 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
The method retrieveEntityInfo() has an NPath complexity of 1296. The configured NPath complexity threshold is 200. Open
public function retrieveEntityInfo(int $record, string $module)
{
\App\Log::trace("Entering into retrieveEntityInfo($record, $module) method.");
if ('' == $record) {
\App\Log::error('record is empty. returning null');
- 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 retrieveEntityInfo() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
public function retrieveEntityInfo(int $record, string $module)
{
\App\Log::trace("Entering into retrieveEntityInfo($record, $module) method.");
if ('' == $record) {
\App\Log::error('record is empty. returning null');
- 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
Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed. Open
public function retrieveEntityInfo(int $record, string $module)
- 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
The class Users has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '153', column '32'). Open
$result[$tableName] = (new \App\Db\Query())->from($tableName)->where([$this->tab_name_index[$tableName] => $record])->one();
- 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 '166', column '21'). Open
$currency = (new \App\Db\Query())->from('vtiger_currency_info')->where(['id' => $this->column_fields['currency_id'], 'deleted' => 0])->one();
- 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 '242', column '19'). Open
$result = (new \App\Db\Query())->select(['id'])->from('vtiger_users')->where(['is_admin' => 'on', 'status' => 'Active'])->scalar();
- 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 '169', column '21'). Open
$currency = (new \App\Db\Query())->from('vtiger_currency_info')->where(['id' => 1])->one();
- 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 '204', column '23'). Open
$eventHandler = new App\EventHandler();
- 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 '155', column '16'). Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_RECORD_NOT_FOUND||' . $record);
- 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\User' in method 'transformOwnerShipAndDelete'. Open
'modified_user_id' => App\User::getCurrentUserRealId(),
- 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 'CRMEntity' in method 'getActiveAdminUser'. Open
$user = CRMEntity::getInstance('Users');
- 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\Field' in method 'retrieveEntityInfo'. Open
$fields = \App\Field::getModuleFieldInfos($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 'vtlib\Deprecated' in method '__construct'. Open
$this->column_fields = vtlib\Deprecated::getColumnFields('Users');
- 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 'retrieveEntityInfo'. Open
$this->column_fields['no_of_currency_decimals'] = $this->no_of_currency_decimals = App\User::getCurrentUserId() ? (int) App\User::getCurrentUserModel()->getDetail('no_of_currency_decimals') : 2;
- 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\Encryption' in method 'createAccessKey'. Open
'accesskey' => \App\Encryption::generatePassword(20, 'lbn'),
- 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 retrieveEntityInfo uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$currencySymbol = $currency['currency_symbol'];
}
- 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 'retrieveEntityInfo'. Open
\App\Log::trace('Exit from retrieveEntityInfo() method.');
- 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\PrivilegeFile' in method 'getActiveAdminId'. Open
$users = \App\PrivilegeFile::getUser('id');
- 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 getActiveAdminId uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$adminId = 1;
$result = (new \App\Db\Query())->select(['id'])->from('vtiger_users')->where(['is_admin' => 'on', 'status' => 'Active'])->scalar();
if ($result) {
$adminId = $result;
- 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 'retrieveEntityInfo'. Open
\App\Log::trace("Entering into retrieveEntityInfo($record, $module) method.");
- 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\UserPrivilegesFile' in method 'createAccessKey'. Open
\App\UserPrivilegesFile::createUserPrivilegesfile($this->id);
- 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 'retrieveCurrentUserInfoFromFile'. Open
$userPrivileges = App\User::getPrivilegesFile($userid);
- 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 'retrieveEntityInfo'. Open
\App\Log::error('record is empty. returning null');
- 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\Fields\Owner' in method 'transformOwnerShipAndDelete'. Open
App\Fields\Owner::transferOwnership($userId, $transformToUserId);
- 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\Config' in method 'getActiveAdminId'. Open
if (App\Config::performance('ENABLE_CACHING_USERS')) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Vtiger_Cache' in method 'getActiveAdminId'. Open
$cache = Vtiger_Cache::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
Define a constant instead of duplicating this literal "last_name" 6 times. Open
'Name' => ['vtiger_users' => 'last_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 "first_name" 4 times. Open
'First Name' => 'first_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 "vtiger_users" 8 times. Open
public $tab_name = ['vtiger_users', 'vtiger_user2role'];
- 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 "currency_code" 3 times. Open
$this->column_fields['currency_code'] = '';
- 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 "is_admin" 3 times. Open
'Admin' => 'is_admin',
- 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 "currency_symbol" 5 times. Open
$this->column_fields['currency_symbol'] = '';
- 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 "email1" 3 times. Open
'Email' => ['vtiger_users' => 'email1'],
- 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 "currency_name" 3 times. Open
$this->column_fields['currency_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 "status" 4 times. Open
'Status' => 'status',
- 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 "Users" 4 times. Open
public $module_name = 'Users';
- 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.
Remove this commented out code. Open
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Define a constant instead of duplicating this literal "no_of_currency_decimals" 3 times. Open
if ('' === $this->column_fields['no_of_currency_decimals']) {
- 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_iter'. Open
foreach ($this->column_fields as $field => $value_iter) {
- 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
Reference to undeclared property \Users->currency_code
Open
$this->column_fields['currency_code'] = $this->currency_code = $currency['currency_code'];
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields = vtlib\Deprecated::getColumnFields('Users');
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_name'] = '';
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
foreach ($this->column_fields as $field => $value_iter) {
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Entering into retrieveEntityInfo($record, $module) method.");
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$result[$tableName] = (new \App\Db\Query())->from($tableName)->where([$this->tab_name_index[$tableName] => $record])->one();
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields[$field] = $userInfo[$field];
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['record_module'] = $module;
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_symbol'] = '';
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$currency = (new \App\Db\Query())->from('vtiger_currency_info')->where(['id' => 1])->one();
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_name'] = $this->currency_name = $currency['currency_name'];
- Exclude checks
Reference to undeclared property \Users->currency_name
Open
$this->column_fields['currency_name'] = $this->currency_name = $currency['currency_name'];
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['conv_rate'] = '';
- Exclude checks
Call to method getPrivilegesFile
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$userPrivileges = App\User::getPrivilegesFile($userid);
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error('record is empty. returning null');
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_code'] = '';
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->{$fieldName} = $this->column_fields[$fieldName] = $result[$tableName][$fieldRow['columnname']];
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['record_id'] = $record;
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$currency = (new \App\Db\Query())->from('vtiger_currency_info')->where(['id' => $this->column_fields['currency_id'], 'deleted' => 0])->one();
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_symbol'] = $this->currency_symbol = $currencySymbol;
- Exclude checks
Saw misspelled annotation @returns.
Did you mean @return?
Open
* @returns user info in $this->column_fields array:: Type array
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_code'] = $this->currency_code = $currency['currency_code'];
- Exclude checks
Reference to undeclared property \Users->currency_symbol_placement
Open
$this->column_fields['currency_symbol_placement'] = $this->currency_symbol_placement = '1.0$';
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
App\Db::getInstance()->createCommand()
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$currency = (new \App\Db\Query())->from('vtiger_currency_info')->where(['id' => $this->column_fields['currency_id'], 'deleted' => 0])->one();
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['conv_rate'] = $this->conv_rate = $currency['conversion_rate'];
- Exclude checks
Reference to undeclared property \Users->conv_rate
Open
$this->column_fields['conv_rate'] = $this->conv_rate = $currency['conversion_rate'];
- Exclude checks
Reference to undeclared property \Users->no_of_currency_decimals
Open
$this->column_fields['no_of_currency_decimals'] = $this->no_of_currency_decimals = App\User::getCurrentUserId() ? (int) App\User::getCurrentUserModel()->getDetail('no_of_currency_decimals') : 2;
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
if ('' == $this->column_fields['currency_grouping_pattern'] && '' == $this->column_fields['currency_symbol_placement']) {
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_decimal_separator'] = $this->currency_decimal_separator = '.';
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->column_fields['no_of_currency_decimals'] = $this->no_of_currency_decimals = App\User::getCurrentUserId() ? (int) App\User::getCurrentUserModel()->getDetail('no_of_currency_decimals') : 2;
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_grouping_pattern'] = $this->currency_grouping_pattern = '123,456,789';
- Exclude checks
Call to method getCurrentUserRealId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
'modified_user_id' => App\User::getCurrentUserRealId(),
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
if (!empty($this->column_fields['currency_id'])) {
- Exclude checks
Reference to undeclared property \Users->currency_symbol
(Did you mean $currencySymbol) Open
$this->column_fields['currency_symbol'] = $this->currency_symbol = $currencySymbol;
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['no_of_currency_decimals'] = $this->no_of_currency_decimals = App\User::getCurrentUserId() ? (int) App\User::getCurrentUserModel()->getDetail('no_of_currency_decimals') : 2;
- Exclude checks
Call to undeclared method \CRMEntity::retrieveCurrentUserInfoFromFile
Open
$user->retrieveCurrentUserInfoFromFile($adminId);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
App\Db::getInstance()->createCommand()
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_symbol_placement'] = $this->currency_symbol_placement = '1.0$';
- Exclude checks
Returning type ?1
but getActiveAdminId()
is declared to return int
Open
return $adminId;
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
if ('' === $this->column_fields['no_of_currency_decimals']) {
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->column_fields['no_of_currency_decimals'] = $this->no_of_currency_decimals = App\User::getCurrentUserId() ? (int) App\User::getCurrentUserModel()->getDetail('no_of_currency_decimals') : 2;
- Exclude checks
Reference to undeclared property \Users->column_fields
Open
$this->column_fields['currency_grouping_separator'] = $this->currency_grouping_separator = ' ';
- Exclude checks
Reference to undeclared property \Users->currency_grouping_separator
Open
$this->column_fields['currency_grouping_separator'] = $this->currency_grouping_separator = ' ';
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$result = (new \App\Db\Query())->select(['id'])->from('vtiger_users')->where(['is_admin' => 'on', 'status' => 'Active'])->scalar();
- Exclude checks
Call to method generatePassword
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
'accesskey' => \App\Encryption::generatePassword(20, 'lbn'),
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Exit from retrieveEntityInfo() method.');
- Exclude checks
Reference to undeclared property \Users->currency_grouping_pattern
Open
$this->column_fields['currency_grouping_pattern'] = $this->currency_grouping_pattern = '123,456,789';
- Exclude checks
Call to method transferOwnership
from undeclared class \App\Fields\Owner
Open
App\Fields\Owner::transferOwnership($userId, $transformToUserId);
- Exclude checks
Reference to undeclared property \Users->currency_decimal_separator
Open
$this->column_fields['currency_decimal_separator'] = $this->currency_decimal_separator = '.';
- Exclude checks
Avoid excessively long variable names like $additional_column_fields. Keep variable name length under 20. Open
public $additional_column_fields = ['reports_to_name'];
- 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 $emailTemplate_defaultFields. Keep variable name length under 20. Open
public $emailTemplate_defaultFields = ['first_name', 'last_name', 'title', 'department', 'phone_home', 'phone_mobile', 'signature', 'email1'];
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Users extends CRMEntity
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 46 and the first side effect is on line 28. Open
<?php
- Exclude checks
The property $object_name is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $user_preferences is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $list_fields_name is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $error_string is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $tab_name is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $tab_name_index is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $default_order_by is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $list_mode is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $default_sort_order is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $new_schema is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
public $id;
- 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
The property $is_admin is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $additional_column_fields is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $module_name is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $popup_fields is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $table_name is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $search_fields_name is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $default_widgets is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $table_index is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $search_fields is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $emailTemplate_defaultFields is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $popup_type is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $record_id is not named in camelCase. Open
class Users extends CRMEntity
{
// Stored fields
public $id;
public $authenticated = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
public $authenticated = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result[$tableName] = (new \App\Db\Query())->from($tableName)->where([$this->tab_name_index[$tableName] => $record])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->{$fieldName} = $this->column_fields[$fieldName] = $result[$tableName][$fieldRow['columnname']];
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
$currency = (new \App\Db\Query())->from('vtiger_currency_info')->where(['id' => $this->column_fields['currency_id'], 'deleted' => 0])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['no_of_currency_decimals'] = $this->no_of_currency_decimals = App\User::getCurrentUserId() ? (int) App\User::getCurrentUserModel()->getDetail('no_of_currency_decimals') : 2;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_symbol_placement'] = $this->currency_symbol_placement = '1.0$';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('Exit from retrieveEntityInfo() method.');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Stored fields
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Role Name' => 'roleid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Default Fields for Email Templates -- Pavani
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to check whether the user is an Admin user.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Entering into retrieveEntityInfo($record, $module) method.");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['record_id'] = $record;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currencySymbol = $currencyArray[$currency['currency_symbol']];
- Exclude checks
Line exceeds 120 characters; contains 206 characters Open
$this->column_fields['no_of_currency_decimals'] = $this->no_of_currency_decimals = App\User::getCurrentUserId() ? (int) App\User::getCurrentUserModel()->getDetail('no_of_currency_decimals') : 2;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_decimal_separator'] = $this->currency_decimal_separator = '.';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_grouping_separator'] = $this->currency_grouping_separator = ' ';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $tab_name = ['vtiger_users', 'vtiger_user2role'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $search_fields_name = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $list_mode;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Login Method' => 'login_method',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $user_preferences;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $emailTemplate_defaultFields = ['first_name', 'last_name', 'title', 'department', 'phone_home', 'phone_mobile', 'signature', 'email1'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'User Name' => 'user_name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['conv_rate'] = '';
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
public $emailTemplate_defaultFields = ['first_name', 'last_name', 'title', 'department', 'phone_home', 'phone_mobile', 'signature', 'email1'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// This is the list of fields that are in the lists.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPrivileges = App\User::getPrivilegesFile($userid);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function retrieveEntityInfo(int $record, string $module)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currency = (new \App\Db\Query())->from('vtiger_currency_info')->where(['id' => 1])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($currency)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Admin' => 'is_admin',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $default_widgets = ['CVLVT', 'UA'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($currencyArray[$currency['currency_symbol']])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' === $this->column_fields['no_of_currency_decimals']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $search_fields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Email' => ['vtiger_users' => 'email1'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'First Name' => 'first_name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** constructor function for the main user class.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool true/false
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' == $record) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' == $this->column_fields['currency_grouping_pattern'] && '' == $this->column_fields['currency_symbol_placement']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_grouping_pattern'] = $this->currency_grouping_pattern = '123,456,789';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $is_admin;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $popup_type;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $list_fields_name = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @returns user info in $this->column_fields array:: Type array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $module_name = 'Users';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($userInfo[$field])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error('record is empty. returning null');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_symbol'] = $this->currency_symbol = $currencySymbol;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Email' => 'email1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $encodeFields = ['first_name', 'last_name', 'description'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_FORCE_PASSWORD_CHANGE' => 'force_password_change',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $table_name = 'vtiger_users';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $default_order_by = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $record_id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields = vtlib\Deprecated::getColumnFields('Users');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_symbol'] = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param $userid -- user id:: Type integer
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_RECORD_NOT_FOUND||' . $record);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Function to get the current user information from the user_privileges file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_code'] = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'First Name' => 'first_name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $default_sort_order = 'ASC';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return isset($this->is_admin) && 'on' === $this->is_admin;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($result[$tableName]) && isset($this->tab_name_index[$tableName])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currency = (new \App\Db\Query())->from('vtiger_currency_info')->where(['id' => $this->column_fields['currency_id'], 'deleted' => 0])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function retrieveCurrentUserInfoFromFile($userid)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isAdminUser()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->id = $userid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_name'] = $this->currency_name = $currency['currency_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($result[$tableName])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->{$field} = $userInfo[$field];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($result[$tableName][$fieldRow['columnname']])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['record_module'] = $module;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['conv_rate'] = $this->conv_rate = $currency['conversion_rate'];
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
if ('' == $this->column_fields['currency_grouping_pattern'] && '' == $this->column_fields['currency_symbol_placement']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $error_string;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $tab_name_index = ['vtiger_users' => 'id', 'vtiger_user2role' => 'userid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $table_index = 'id';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $popup_fields = ['last_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Default Widgests
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->column_fields as $field => $value_iter) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields = \App\Field::getModuleFieldInfos($module);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fields as $fieldName => $fieldRow) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = $fieldRow['tablename'];
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
$result[$tableName] = (new \App\Db\Query())->from($tableName)->where([$this->tab_name_index[$tableName] => $record])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $deleted;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// This is used to retrieve related fields from form posts.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Last Name' => 'last_name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_DATE_PASSWORD_CHANGE' => 'date_password_change',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $new_schema = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_name'] = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($this->column_fields['currency_id'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $object_name = 'User';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $additional_column_fields = ['reports_to_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Status' => 'status',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields[$field] = $userInfo[$field];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currencyArray = ['$' => '$', '€' => '€', '£' => '£', '¥' => '¥'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currencySymbol = $currency['currency_symbol'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->column_fields['currency_code'] = $this->currency_code = $currency['currency_code'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Name' => ['vtiger_users' => 'last_name'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Name' => 'last_name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userInfo = $userPrivileges['user_info'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->id = $record;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'modified_user_id' => App\User::getCurrentUserRealId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the active admin user object.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user = CRMEntity::getInstance('Users');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'date_modified' => date('Y-m-d H:i:s'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler->setParams(['userId' => $userId, 'transformToUserId' => $transformToUserId]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler->trigger('UsersBeforeDelete');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//updating the vtiger_users table
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
App\Db::getInstance()->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'status' => 'Inactive',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the user if of the active admin user.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($users as $id => $user) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Users - Active Admin User Instance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
App\Db::getInstance()->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $userId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Transform owner ship and delete.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
], ['id' => $userId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$adminId = $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $cache->getAdminUserId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$users = \App\PrivilegeFile::getUser('id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cache = Vtiger_Cache::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$adminId = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user->retrieveCurrentUserInfoFromFile($adminId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int - Active Admin User ID
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$adminId = $result;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$adminId = self::getActiveAdminId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Active' == $user['status'] && 'on' == $user['is_admin']) {
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
$result = (new \App\Db\Query())->select(['id'])->from('vtiger_users')->where(['is_admin' => 'on', 'status' => 'Active'])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cache->setAdminUserId($adminId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getActiveAdminUser()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->update('vtiger_users', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\UserPrivilegesFile::createUserPrivilegesfile($this->id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $transformToUserId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function transformOwnerShipAndDelete($userId, $transformToUserId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $user;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function createAccessKey()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler->trigger('UsersAfterDelete');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = (new \App\Db\Query())->select(['id'])->from('vtiger_users')->where(['is_admin' => 'on', 'status' => 'Active'])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
App\Fields\Owner::transferOwnership($userId, $transformToUserId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'deleted' => 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getActiveAdminId()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($result) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->update('vtiger_users', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler = new App\EventHandler();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler->setModuleName('Users');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($cache->getAdminUserId()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (App\Config::performance('ENABLE_CACHING_USERS')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $adminId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'accesskey' => \App\Encryption::generatePassword(20, 'lbn'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
], ['id' => $this->id])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
The variable $value_iter is not named in camelCase. Open
public function retrieveCurrentUserInfoFromFile($userid)
{
$userPrivileges = App\User::getPrivilegesFile($userid);
$userInfo = $userPrivileges['user_info'];
foreach ($this->column_fields as $field => $value_iter) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}