Method testAddSharedAccessPolicy
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testAddSharedAccessPolicy()
{
$sourceId = 'Groups:2';
$targetId = 'Groups:2';
$permission = 0;
Method saveRule
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function saveRule($forModule, $ruleId, $permission, $sourceId, $targetId)
Avoid using undefined variables such as '$dataShareTableColArr' which will lead to PHP notices. Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$newValues' which will lead to PHP notices. Open
$newValues['permission'] = $permission;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$dataShareTableColArr' which will lead to PHP notices. Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$relationTypeComponents[0]][$relationTypeComponents[1]];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$prevValues' which will lead to PHP notices. Open
$prevValues['permission'] = $ruleModel->getPermission();
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$newValues' which will lead to PHP notices. Open
\Settings_Vtiger_Tracker_Model::addDetail($prevValues, $newValues);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$dataShareTableColArr' which will lead to PHP notices. Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$dataShareTableColArr' which will lead to PHP notices. Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$prevValues' which will lead to PHP notices. Open
\Settings_Vtiger_Tracker_Model::addDetail($prevValues, $newValues);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '84', column '21'). Open
$ruleModel = new \Settings_SharingAccess_Rule_Model();
- 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 '120', column '27'). Open
$this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
- 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 '159', column '27'). Open
$this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');
- 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 '55', column '16'). Open
$row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->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 '155', column '27'). Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');
- 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 '177', column '27'). Open
$this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);
- 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 '44', column '15'). Open
$row = (new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->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 '167', column '15'). Open
$row = (new \App\Db\Query())->from('vtiger_def_org_share')->where(['tabid' => 6])->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 '130', column '16'). Open
$row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->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
Avoid using static access to class '\Settings_Vtiger_Tracker_Model' in method 'saveRule'. Open
\Settings_Vtiger_Tracker_Model::addDetail($prevValues, $newValues);
- 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 saveRule uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
}
- 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 '\Settings_SharingAccess_RuleMember_Model' in method 'testEditSharedAccessPolicy'. Open
$targetIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($targetId);
- 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 '\Settings_SharingAccess_Module_Model' in method 'changePermissions'. Open
\Settings_SharingAccess_Module_Model::recalculateSharingRules();
- 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 '\Settings_SharingAccess_Rule_Model' in method 'saveRule'. Open
$ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
- 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 '\Settings_Vtiger_Tracker_Model' in method 'saveRule'. Open
\Settings_Vtiger_Tracker_Model::lockTracking(false);
- 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 '\Settings_Vtiger_Tracker_Model' in method 'testDeleteSharedAccessPolicy'. Open
\Settings_Vtiger_Tracker_Model::lockTracking(false);
- 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 '\Settings_SharingAccess_Rule_Model' in method 'testDeleteSharedAccessPolicy'. Open
$ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, self::$shareId);
- 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 '\Settings_Vtiger_Tracker_Model' in method 'testDeleteSharedAccessPolicy'. Open
\Settings_Vtiger_Tracker_Model::addBasic('delete');
- 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 '\Settings_Vtiger_Tracker_Model' in method 'changePermissions'. Open
\Settings_Vtiger_Tracker_Model::addDetail($prevValues, $postValues);
- 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 '\Settings_SharingAccess_Module_Model' in method 'testDeleteSharedAccessPolicy'. Open
$moduleModel = \Settings_SharingAccess_Module_Model::getInstance($forModule);
- 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 '\Settings_SharingAccess_RuleMember_Model' in method 'testAddSharedAccessPolicy'. Open
$targetIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($targetId);
- 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 '\Settings_SharingAccess_RuleMember_Model' in method 'testEditSharedAccessPolicy'. Open
$sourceIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($sourceId);
- 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 '\Settings_Vtiger_Tracker_Model' in method 'saveRule'. Open
\Settings_Vtiger_Tracker_Model::addBasic('save');
- 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 '\Settings_SharingAccess_RuleMember_Model' in method 'testAddSharedAccessPolicy'. Open
$sourceIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($sourceId);
- 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 '\Settings_SharingAccess_Module_Model' in method 'saveRule'. Open
$moduleModel = \Settings_SharingAccess_Module_Model::getInstance($forModule);
- 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 '\Settings_SharingAccess_Module_Model' in method 'changePermissions'. Open
$moduleModel = \Settings_SharingAccess_Module_Model::getInstance($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
Define a constant instead of duplicating this literal "relationtype" 4 times. Open
self::$relationType = $ruleModel->get('relationtype');
- 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 "No record id: " 3 times. Open
$this->assertNotFalse($row, 'No record id: ' . self::$shareId);
- 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 "source_id" 3 times. Open
$sourceColumnName = $tableColumnInfo['source_id'];
- 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 "tabid" 3 times. Open
$this->assertSame($ruleModel->getModule()->getId(), $row['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 "Groups:2" 3 times. Open
$sourceId = 'Groups: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 "Accounts" 3 times. Open
$forModule = 'Accounts';
- 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.
Rename "$relationType" which has the same name as the field declared at line 24. Open
$relationType = implode('::', [$sourceType, $targetType]);
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Define a constant instead of duplicating this literal "target_id" 3 times. Open
$targetColumnName = $tableColumnInfo['target_id'];
- 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 "permission" 10 times. Open
$this->assertSame($permission, $row2['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 "table" 5 times. Open
$tableName = $tableColumnInfo['table'];
- 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 "Record id " 3 times. Open
$this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
- 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 "shareid" 7 times. Open
self::$shareId = $ruleModel->get('shareid');
- 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.
Rename "$relationType" which has the same name as the field declared at line 24. Open
$relationType = $ruleModel->get('relationtype');
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Define a constant instead of duplicating this literal " should not exist" 3 times. Open
$this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
- 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.
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame($relationType, $row['relationtype']);
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertFalse
Open
$this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
- Exclude checks
Call to method get
on non-class type array
Open
$relationType = $ruleModel->get('relationtype');
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertFalse
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->one();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertNotFalse
Open
$this->assertNotFalse($row, 'No record id: ' . self::$shareId);
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame((string) $targetIdComponents[1], (string) $row2[$targetColumnName]);
- Exclude checks
Variable $newValues
was undeclared, but array fields are being added to it. Open
$newValues['permission'] = $permission;
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertNotFalse
Open
$this->assertNotFalse($row2, 'No record id: ' . self::$shareId);
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame((string) $sourceIdComponents[1], (string) $row2[$sourceColumnName]);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertNotFalse
Open
$this->assertNotFalse($row2, 'No record id: ' . self::$shareId);
- Exclude checks
Variable $prevValues
was undeclared, but array fields are being added to it. Open
$prevValues['permission'] = $ruleModel->getPermission();
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame((string) $targetIdComponents[1], (string) $row2[$targetColumnName]);
- Exclude checks
Call to method delete
on non-class type array
Open
$ruleModel->delete();
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertNotFalse
Open
$this->assertNotFalse($row, 'No record id: 6');
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame($ruleModel->getModule()->getId(), $row['tabid']);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('vtiger_def_org_share')->where(['tabid' => 6])->one();
- Exclude checks
Call to method getId
on non-class type string
Open
$this->assertSame($ruleModel->getModule()->getId(), $row['tabid']);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame($permission, $row2['permission']);
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertFalse
Open
$this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame($permission, $row2['permission']);
- Exclude checks
Call to undeclared method \Tests\Settings\SharingAccess::assertSame
Open
$this->assertSame((string) $sourceIdComponents[1], (string) $row2[$sourceColumnName]);
- Exclude checks
Avoid excessively long variable names like $relationTypeComponents. Keep variable name length under 20. Open
$relationTypeComponents = explode('::', self::$relationType);
- 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 $relationTypeComponents. Keep variable name length under 20. Open
$relationTypeComponents = \explode('::', self::$relationType);
- 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 $relationTypeComponents. Keep variable name length under 20. Open
$relationTypeComponents = explode('::', $relationType);
- 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
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
private static $relationType;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($ruleModel->getModule()->getId(), $row['tabid']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceColumnName = $tableColumnInfo['source_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$forModule = 'Accounts';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetType = $relationTypeComponents[1];
- 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
$permission = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleModel = $this->saveRule($forModule, $ruleId, $permission, $sourceId, $targetId);
- 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
$sourceIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($sourceId);
- 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
$row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($permission, $row2['permission']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Share id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceId = 'Groups:2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetId = 'Groups:2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($row, 'No record id: ' . self::$shareId);
- 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
self::$shareId = $ruleModel->get('shareid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationTypeComponents = \explode('::', self::$relationType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($targetId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing add shared access policy.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceType = $relationTypeComponents[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationType = implode('::', [$sourceType, $targetType]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleId = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetColumnName = $tableColumnInfo['target_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testAddSharedAccessPolicy()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($row2, 'No record id: ' . self::$shareId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$relationType = $ruleModel->get('relationtype');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = $tableColumnInfo['table'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $shareId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($relationType, $row['relationtype']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Relation type.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $forModule
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $permission
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \Settings_SharingAccess_Rule_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Settings_Vtiger_Tracker_Model::lockTracking(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
$this->changePermissions($modulePermissions);
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
$this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);
- 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
\Settings_Vtiger_Tracker_Model::addBasic('save');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testEditSharedAccessPolicy()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetId = 'Roles:H6';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permission = 1;
- 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
$row = (new \App\Db\Query())->from('vtiger_def_org_share')->where(['tabid' => 6])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prevValues[$tabId] = $permissionOld;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = $tableColumnInfo['table'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleModel->delete();
- 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
private function saveRule($forModule, $ruleId, $permission, $sourceId, $targetId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($ruleId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Settings_Vtiger_Tracker_Model::addDetail($prevValues, $newValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetColumnName = $tableColumnInfo['target_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($row2, 'No record id: ' . self::$shareId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $sourceIdComponents[1], (string) $row2[$sourceColumnName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $modulePermissions
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function changePermissions($modulePermissions)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permission = (int) $permission;
- 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
$ruleModel = new \Settings_SharingAccess_Rule_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prevValues['permission'] = $ruleModel->getPermission();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing edit shared access policy.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$forModule = 'Accounts';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
- Exclude checks
Line exceeds 120 characters; contains 199 characters Open
$this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($permission, $row2['permission']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Settings_Vtiger_Tracker_Model::addBasic('delete');
- 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
$modulePermissions[4] = $modulePermissions[6];
- 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
$ruleModel->setModuleFromInstance($moduleModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newValues['permission'] = $permission;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleModel->set('target_id', $targetId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$relationTypeComponents[0]][$relationTypeComponents[1]];
- 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
$permissionOld = (int) $moduleModel->get('permission');
- 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
$ruleModel->set('source_id', $sourceId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationTypeComponents = explode('::', $relationType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Save permissions.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($sourceId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testDeleteSharedAccessPolicy()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->changePermissions($modulePermissions);
- 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
$sourceType = $relationTypeComponents[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $targetIdComponents[1], (string) $row2[$targetColumnName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationType = $ruleModel->get('relationtype');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldPermission = $row['permission'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($modulePermissions as $tabId => $permission) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $ruleId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $sourceId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationTypeComponents = explode('::', self::$relationType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetType = $relationTypeComponents[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newPermission = 2 === $oldPermission ? 1 : 2;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($modulePermissions as $tabId => $permission) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$postValues[$tabId] = (int) $moduleModel->get('permission');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $targetIdComponents[1], (string) $row2[$targetColumnName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
$tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$relationTypeComponents[0]][$relationTypeComponents[1]];
- 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
\Settings_SharingAccess_Module_Model::recalculateSharingRules();
- 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
$sourceId = 'Groups:2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceType = $relationTypeComponents[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
$forModule = 'Accounts';
- 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
$moduleModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $sourceIdComponents[1], (string) $row2[$sourceColumnName]);
- 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 $ruleModel;
- 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
$row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($targetId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testChangePermissions()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modulePermissions = [6 => $oldPermission, 4 => $oldPermission];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prevValues = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Settings_SharingAccess_Module_Model::getInstance($tabId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetType = $relationTypeComponents[1];
- 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
\Settings_Vtiger_Tracker_Model::lockTracking(false);
- Exclude checks
Line exceeds 120 characters; contains 188 characters Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');
- 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
* Change of permissions.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$postValues = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($permissionOld !== $permission) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleModel->set('permission', $permission);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleModel = $this->saveRule($forModule, self::$shareId, $permission, $sourceId, $targetId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationTypeComponents = \explode('::', $ruleModel->get('relationtype'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceColumnName = $tableColumnInfo['source_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing delete shared access policy.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Settings_SharingAccess_Module_Model::getInstance($forModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing permission changes.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($row, 'No record id: 6');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modulePermissions = [6 => $newPermission, 4 => $newPermission];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->set('permission', $permission);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $targetId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Settings_SharingAccess_Module_Model::getInstance($forModule);
- 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
$tableName = $tableColumnInfo['table'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, self::$shareId);
- Exclude checks
Line exceeds 120 characters; contains 229 characters Open
$this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');
- 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
\Settings_Vtiger_Tracker_Model::addDetail($prevValues, $postValues);
- Exclude checks