Method setRelatedList
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'getRelatedList', $fieldName = null, $fields = [])
{
$db = \App\Db::getInstance();
if (empty($moduleInstance)) {
return;
Function createFiles
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function createFiles(Field $entityField)
{
$targetpath = 'modules/' . $this->name;
if (!is_file($targetpath)) {
- 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 createFiles
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createFiles(Field $entityField)
{
$targetpath = 'modules/' . $this->name;
if (!is_file($targetpath)) {
Function setRelatedList
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'getRelatedList', $fieldName = null, $fields = [])
{
$db = \App\Db::getInstance();
if (empty($moduleInstance)) {
return;
- 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 setRelatedList
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'getRelatedList', $fieldName = null, $fields = [])
Method addLink
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addLink($type, $label, $url, $iconpath = '', $sequence = 0, $handlerInfo = null)
The method setRelatedList() has an NPath complexity of 288. The configured NPath complexity threshold is 200. Open
public function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'getRelatedList', $fieldName = null, $fields = [])
{
$db = \App\Db::getInstance();
if (empty($moduleInstance)) {
return;
- 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 setRelatedList() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'getRelatedList', $fieldName = null, $fields = [])
{
$db = \App\Db::getInstance();
if (empty($moduleInstance)) {
return;
- 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 20 to the 15 allowed. Open
public function createFiles(Field $entityField)
- 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 Module has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13. Open
class Module extends ModuleBasic
{
/**
* Allow export.
*
- 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 '144', column '14'). Open
$id = (new \App\Db\Query())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '216', column '19'). Open
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($templatepath, $flags), \RecursiveIteratorIterator::SELF_FIRST);
- 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 '92', column '22'). Open
$allFields = (new \App\Db\Query())->select(['fieldid', 'fieldname'])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method setRelatedList has a boolean flag argument $actions, which is a certain sign of a Single Responsibility Principle violation. Open
public function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'getRelatedList', $fieldName = null, $fields = [])
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '339', column '27'). Open
$menuRecordModel = new \Settings_Menu_Record_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 '33', column '15'). Open
return (new \App\Db\Query())->from('vtiger_relatedlists')->where(['tabid' => $this->id])->max('sequence') + 1;
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '68', column '20'). Open
$isExists = (new \App\Db\Query())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method deleteLink has a boolean flag argument $url, which is a certain sign of a Single Responsibility Principle violation. Open
public function deleteLink($type, $label, $url = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '216', column '50'). Open
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($templatepath, $flags), \RecursiveIteratorIterator::SELF_FIRST);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method createFiles uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fileContent = file_get_contents($name);
$replacevars = [
'<ModuleName>' => $this->name,
'<ModuleLabel>' => $this->label,
- 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 'vtlib\Utils' in method 'getClassInstance'. Open
if (Utils::checkFileAccessForInclusion($filepath, 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 'vtlib\Link' in method 'deleteLink'. Open
Link::deleteLink($this->id, $type, $label, $url);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'toggleModuleAccess'. Open
$tabId = \App\Module::getModuleId($moduleName);
- 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\Link' in method 'getLinks'. Open
return Link::getAll($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\Cache' in method 'toggleModuleAccess'. Open
\App\Cache::delete('moduleTabById', $tabId);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Relation' in method 'unsetRelatedList'. Open
\App\Relation::clearCacheById($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 '\Settings_GlobalPermission_Record_Model' in method 'toggleModuleAccess'. Open
\Settings_GlobalPermission_Record_Model::recalculate();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'toggleModuleAccess'. Open
\App\Module::createModuleMetaFile();
- 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 'setRelatedList'. Open
\App\Log::trace("Setting relation with $moduleInstance->name [$useactionsText] ... Error, the related module already exists", __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 'vtlib\Link' in method 'addLink'. Open
Link::addLink($this->id, $type, $label, $url, $iconpath, $sequence, $handlerInfo);
- 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\Webservice' in method 'initWebservice'. Open
Webservice::initialize($this);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'createFiles'. Open
$languages = \App\Language::getAll(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 '\App\Log' in method 'fireEvent'. Open
\App\Log::trace("Invoking moduleHandler for $eventType ...DONE", __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\Cache' in method 'toggleModuleAccess'. Open
\App\Cache::staticDelete('module', $moduleName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'toggleModuleAccess'. Open
\App\Cache::delete('moduleTabs', 'all');
- 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 'getClassInstance'. Open
Deprecated::checkFileAccessForInclusion($filepath);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'setRelatedList'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'fireEvent'. Open
\App\Log::trace("Invoking moduleHandler for $eventType ...START", __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\Cache' in method 'toggleModuleAccess'. Open
\App\Cache::delete('moduleTabByName', $moduleName);
- 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_Relation_Model' in method 'setRelatedList'. Open
$refTableName = \Vtiger_Relation_Model::getReferenceTableInfo($moduleInstance->name, $this->name);
- 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 'setRelatedList'. Open
\App\Log::trace("Setting relation with $moduleInstance->name ... DONE", __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\Log' in method 'unsetRelatedList'. Open
\App\Log::trace("Unsetting relation with $moduleInstance->name ... DONE", __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 'vtlib\Functions' in method 'getInstance'. Open
$data = Functions::getModuleData($value);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'setRelatedList'. Open
\App\Cache::clear();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'toggleModuleAccess'. Open
\App\Cache::staticDelete('module', $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 "fieldid" 3 times. Open
$allFields = (new \App\Db\Query())->select(['fieldid', 'fieldname'])
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "label" 3 times. Open
->where(['tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $functionName, 'label' => $label, 'field_name' => $fieldName])
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "table" 10 times. Open
if (!$schema->getTableSchema($refTableName['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 "related_tabid" 3 times. Open
->where(['tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $functionName, 'label' => $label, 'field_name' => $fieldName])
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "vtiger_relatedlists" 5 times. Open
return (new \App\Db\Query())->from('vtiger_relatedlists')->where(['tabid' => $this->id])->max('sequence') + 1;
- 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" 5 times. Open
return (new \App\Db\Query())->from('vtiger_relatedlists')->where(['tabid' => $this->id])->max('sequence') + 1;
- 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 "crmid" 5 times. Open
'crmid' => 'int',
- 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 "relcrmid" 3 times. Open
'relcrmid' => 'int',
- 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 "relation_id" 5 times. Open
->select(['relation_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 "sequence" 3 times. Open
return (new \App\Db\Query())->from('vtiger_relatedlists')->where(['tabid' => $this->id])->max('sequence') + 1;
- 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 '$object'. Open
foreach ($objects as $name => $object) {
- 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
Avoid unused local variables such as '$language'. Open
foreach ($languages as $prefix => $language) {
- 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
Argument 1 (str)
is false
but \strtolower()
takes string
Open
'<_baseTableName_>' => 'u_' . (\App\Db::getInstance()->getConfig('base')['tablePrefix']) . strtolower($this->name),
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Label to display in related list (default is target module name)':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Label to display in related list (default is target module name)
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$isExists = (new \App\Db\Query())
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Callback function name of this module to use as handler':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Callback function name of this module to use as handler
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$id = (new \App\Db\Query())
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string HREF value to use for generated link':
after string,
did not see an element name (will guess based on comment order) Open
* @param string HREF value to use for generated link
- Exclude checks
Argument 1 (tabid)
is false
but \vtlib\Link::deleteLink()
takes int
defined at /code/vtlib/Vtiger/Link.php:119
Open
Link::deleteLink($this->id, $type, $label, $url);
- Exclude checks
Argument 1 (str)
is false
but \strtolower()
takes string
Open
'<modulename>' => strtolower($this->name),
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Setting relation with $moduleInstance->name [$useactionsText] ... Error, the related module already exists", __METHOD__);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->createIndex("{$refTableName['table']}_relcrmid_idx", $refTableName['table'], 'relcrmid')->execute();
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Type can be like 'DETAIL_VIEW_BASIC', 'LISTVIEW' etc..':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Type can be like 'DETAIL_VIEW_BASIC', 'LISTVIEW' etc..
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param \Module Instance of target module with which relation should be setup':
after \Module,
did not see an element name (will guess based on comment order) Open
* @param \Module Instance of target module with which relation should be setup
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Path to the image file (relative or absolute)':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Path to the image file (relative or absolute)
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->addForeignKey(
- Exclude checks
Argument 1 (tabid)
is false
but \vtlib\Link::getAll()
takes int
defined at /code/vtlib/Vtiger/Link.php:158
Open
return Link::getAll($this->id);
- Exclude checks
Suspicious type false
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$targetpath = 'modules/' . $this->name;
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param Module Instance of target module with which relation should be setup':
after Module,
did not see an element name (will guess based on comment order) Open
* @param Module Instance of target module with which relation should be setup
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->createIndex("{$refTableName['table']}_crmid_idx", $refTableName['table'], 'crmid')->execute();
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param int Sequence of appearance':
after int,
did not see an element name (will guess based on comment order) Open
* @param int Sequence of appearance
- Exclude checks
Suspicious type false
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$langFile = 'languages/' . \App\Language::DEFAULT_LANG . '/' . $this->name . '.json';
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
return (new \App\Db\Query())->from('vtiger_relatedlists')->where(['tabid' => $this->id])->max('sequence') + 1;
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$allFields = (new \App\Db\Query())->select(['fieldid', 'fieldname'])
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('vtiger_relatedlists', [
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('vtiger_relatedlists_fields', [
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Setting relation with $moduleInstance->name ... DONE", __METHOD__);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$createCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Unsetting relation with $moduleInstance->name ... DONE", __METHOD__);
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param array List of action button to show ('ADD', 'SELECT')':
after array,
did not see an element name (will guess based on comment order) Open
* @param array List of action button to show ('ADD', 'SELECT')
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Label to use for display':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Label to use for display
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Display label to lookup':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Display label to lookup
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->addForeignKey(
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Label to display in related list (default is target module name)':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Label to display in related list (default is target module name)
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Type can be like 'DETAIL_VIEW_BASIC', 'LISTVIEW' etc..':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Type can be like 'DETAIL_VIEW_BASIC', 'LISTVIEW' etc..
- Exclude checks
Argument 1 (tabid)
is false
but \vtlib\Link::addLink()
takes int
defined at /code/vtlib/Vtiger/Link.php:80
Open
Link::addLink($this->id, $type, $label, $url, $iconpath, $sequence, $handlerInfo);
- Exclude checks
Argument 2 (replace)
is false
but \str_replace()
takes array|string
Open
$targetPath = str_replace('_ModuleName_', $this->name, $targetPath);
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Callback function name of this module to use as handler':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Callback function name of this module to use as handler
- Exclude checks
Call to undeclared method \App\Db::getSchema
Open
$schema = $db->getSchema();
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string URL value to lookup':
after string,
did not see an element name (will guess based on comment order) Open
* @param string URL value to lookup
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string Module name':
after string,
did not see an element name (will guess based on comment order) Open
* @param string Module name
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->update('vtiger_tab', ['presence' => $enableDisable], ['name' => $moduleName])->execute();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Invoking moduleHandler for $eventType ...START", __METHOD__);
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param mixed id or name of the module':
after mixed,
did not see an element name (will guess based on comment order) Open
* @param mixed id or name of the module
- Exclude checks
Argument 2 (key)
is bool|int
but \App\Cache::staticDelete()
takes string
defined at /code/app/Cache.php:169
Open
\App\Cache::staticDelete('module', $tabId);
- Exclude checks
Suspicious type false
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
copy($langFile, 'languages/' . $prefix . '/' . $this->name . '.json');
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Invoking moduleHandler for $eventType ...DONE", __METHOD__);
- Exclude checks
Argument 2 (key)
is bool|int
but \App\Cache::delete()
takes string
defined at /code/app/Cache.php:105
Open
\App\Cache::delete('moduleTabById', $tabId);
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = (new \App\Db\Query())
- 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
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = $db->getLastInsertID('vtiger_relatedlists_relation_id_seq');
- 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
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The parameter $function_name is not named in camelCase. Open
public function unsetRelatedList($moduleInstance, $label = '', $function_name = 'getRelatedList')
{
if (empty($moduleInstance)) {
return;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Only one argument is allowed per line in a multi-line function call Open
"fk_1_{$refTableName['table']}", $refTableName['table'], 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_2_{$refTableName['table']}", $refTableName['table'], 'relcrmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_2_{$refTableName['table']}", $refTableName['table'], 'relcrmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_1_{$refTableName['table']}", $refTableName['table'], 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_1_{$refTableName['table']}", $refTableName['table'], 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_2_{$refTableName['table']}", $refTableName['table'], 'relcrmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_2_{$refTableName['table']}", $refTableName['table'], 'relcrmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_1_{$refTableName['table']}", $refTableName['table'], 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_1_{$refTableName['table']}", $refTableName['table'], 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_1_{$refTableName['table']}", $refTableName['table'], 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_2_{$refTableName['table']}", $refTableName['table'], 'relcrmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
"fk_2_{$refTableName['table']}", $refTableName['table'], 'relcrmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- 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
* @param Module Instance of target module with which relation should be setup
- 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
$label = $moduleInstance->name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array List of action button to show ('ADD', 'SELECT')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$useactionsText = $actions;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string Callback function name of this module to use as handler
- 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 function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'getRelatedList', $fieldName = null, $fields = [])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$useactionsText = strtoupper($useactionsText);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$isExists = (new \App\Db\Query())
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
\App\Log::trace("Setting relation with $moduleInstance->name [$useactionsText] ... Error, the related module already exists", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => $label,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'relation_id' => $id,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->createIndex("{$refTableName['table']}_relcrmid_idx", $refTableName['table'], 'relcrmid')->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->exists();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->addForeignKey(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sequence' => $sequence,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_field')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
"fk_2_{$refTableName['table']}", $refTableName['table'], 'relcrmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'fieldid' => $allFields[$value]['fieldid'],
- 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
$id = (new \App\Db\Query())
- 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
* @param mixed $iconpath
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $sequence
- 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
* @param mixed|null $handlerInfo
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetPath = str_replace('_ModuleName_', $this->name, $targetPath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $label
- 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
* Get all the custom links related to this module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Initialize webservice setup for this module instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function initWebservice()
- 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
$replacevars = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'<ModuleLabel>' => $this->label,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $fields
- 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
->select(['relation_id'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tabid' => $this->id,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'presence' => $presence,
- 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
->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$createCommand->delete('vtiger_relatedlists', ['relation_id' => $id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string Label to use for display
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* $RECORD (record on which link is dispalyed)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string Display label to lookup
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetpath = 'modules/' . $this->name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($objects as $name => $object) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'<ModuleName>' => $this->name,
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
'<_baseTableName_>' => 'u_' . (\App\Db::getInstance()->getConfig('base')['tablePrefix']) . strtolower($this->name),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'field_name' => $fieldName,
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
"fk_2_{$refTableName['table']}", $refTableName['table'], 'relcrmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- 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
* @param string Type can be like 'DETAIL_VIEW_BASIC', 'LISTVIEW' etc..
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string URL value to lookup
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $type
- 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
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$actions = ['ADD'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_relatedlists')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'related_tabid' => $moduleInstance->id,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'relcrmid' => 'int',
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
$db->createCommand()->createIndex("{$refTableName['table']}_relcrmid_idx", $refTableName['table'], 'relcrmid')->execute();
- 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
* NOTE: $url can have variables like $MODULE (module for which link is associated),
- 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
$templatepath = 'vtlib/ModuleDir/BaseModule/';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!is_dir($targetPath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $allowExport = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get related list sequence to use.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
->where(['tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $functionName, 'label' => $label, 'field_name' => $fieldName])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fields) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->indexBy('fieldname')->all();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createTable($refTableName['table'], [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Setting relation with $moduleInstance->name ... DONE", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($label)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['relation_id'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$createCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function addLink($type, $label, $url, $iconpath = '', $sequence = 0, $handlerInfo = null)
- 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 function deleteLink($type, $label, $url = 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getLinks()
- 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 ($isExists) {
- 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 ('getManyToMany' === $functionName) {
- 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
* @param string Label to display in related list (default is target module name)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_relatedlists')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $function_name, 'label' => $label])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Add custom link for a module page.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $url
- 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 (is_dir($name)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'<entityfieldlabel>' => $entityField->label,
- 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
* Set related list information between other module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $functionName, 'label' => $label, 'field_name' => $fieldName])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->createIndex("{$refTableName['table']}_crmid_idx", $refTableName['table'], 'crmid')->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->addForeignKey(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function unsetRelatedList($moduleInstance, $label = '', $function_name = 'getRelatedList')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Relation::clearCacheById($id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Unsetting relation with $moduleInstance->name ... DONE", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string Path to the image file (relative or absolute)
- 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($label)) {
- 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
* @param string Callback function name of this module to use as handler
- 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
'<_baseTableName_>' => 'u_' . (\App\Db::getInstance()->getConfig('base')['tablePrefix']) . strtolower($this->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
'actions' => $useactionsText,
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
$db->createCommand()->createIndex("{$refTableName['table']}_crmid_idx", $refTableName['table'], 'crmid')->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Unset related list information that exists with other module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $label
- 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
Link::deleteLink($this->id, $type, $label, $url);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $moduleInstance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $fieldName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($actions)) {
- 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
'sequence' => $key,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$schema = $db->getSchema();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$schema->getTableSchema($refTableName['table'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Module Instance of target module with which relation should be setup
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $function_name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($moduleInstance)) {
- 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
* @param mixed $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Link::addLink($this->id, $type, $label, $url, $iconpath, $sequence, $handlerInfo);
- 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
Webservice::initialize($this);
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($templatepath, $flags), \RecursiveIteratorIterator::SELF_FIRST);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
mkdir($targetPath, 0755);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'<entityfieldname>' => $entityField->name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'_ModuleName_' => $this->name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Allow export.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $actions
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $functionName
- 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
'name' => $functionName,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allFields = (new \App\Db\Query())->select(['fieldid', 'fieldname'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['tabid' => $moduleInstance->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
}
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
"fk_1_{$refTableName['table']}", $refTableName['table'], 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- 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
public function createFiles(Field $entityField)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __getNextRelatedListSequence()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $label
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Allow ADD action of other module records (default)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false === $actions) {
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$createCommand->delete('vtiger_relatedlists_fields', ['relation_id' => $id])->execute();
- 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
* Delete custom link of a module.
- 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 (!is_file($targetpath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($templatepath, $flags), \RecursiveIteratorIterator::SELF_FIRST);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetPath = str_replace($templatepath, '', $name);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string Label to display in related list (default is target module name)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sequence = $this->__getNextRelatedListSequence();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('vtiger_relatedlists_fields', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$refTableName = \Vtiger_Relation_Model::getReferenceTableInfo($moduleInstance->name, $this->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
* @param string HREF value to use for generated link
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $label
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string Type can be like 'DETAIL_VIEW_BASIC', 'LISTVIEW' etc..
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileContent = file_get_contents($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
$useactionsText = implode(',', $actions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Setting relation with $moduleInstance->name [$useactionsText] ... Error, the related module already exists", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = $moduleInstance->name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int Sequence of appearance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Link::getAll($this->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
'<modulename>' => strtolower($this->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
return (new \App\Db\Query())->from('vtiger_relatedlists')->where(['tabid' => $this->id])->max('sequence') + 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
public function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'getRelatedList', $fieldName = null, $fields = [])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($moduleInstance)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$presence = 0; // 0 - Enabled, 1 - Disabled
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('vtiger_relatedlists', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$id = $db->getLastInsertID('vtiger_relatedlists_relation_id_seq');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fields as $key => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'crmid' => 'int',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
"fk_1_{$refTableName['table']}", $refTableName['table'], 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::clear();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $moduleInstance
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
->where(['tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $function_name, 'label' => $label])
- 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
'<entitycolumn>' => $entityField->column,
- 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
* @param mixed $value
- 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
* Get instance of the module class.
- 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 (null !== $fire && true !== $fire) {
- 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 $return;
- 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 bool
- 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 self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstance($value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $modulename
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $eventType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Invoking moduleHandler for $eventType ...START", __METHOD__);
- 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
$eventType = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isModuleUpgradable(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Deprecated::checkFileAccessForInclusion($filepath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function fireEvent($modulename, $eventType)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('moduleTabByName', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if this module is customized.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->allowExport || ($this->isCustomizable() && 0 === $this->premium);
- 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 (\App\Language::DEFAULT_LANG !== $prefix) {
- 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
\App\Log::trace("Invoking moduleHandler for $eventType ...DONE", __METHOD__);
- 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 static function toggleModuleAccess($moduleName, $enableDisable)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$enableDisable = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventType = self::EVENT_MODULE_ENABLED;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::staticDelete('module', $moduleName);
- 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
* Fire the event for the module (if moduleHandler is defined).
- 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 function isCustomizable(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$languages = \App\Language::getAll(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get instance by id or name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->initialize($data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$filepath = "modules/$modulename/$modulename.php";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (true === $enableDisable) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('moduleTabById', $tabId);
- 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 (Utils::checkFileAccessForInclusion($filepath, false)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$enableDisable = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::staticDelete('module', $tabId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->isCustomizable() && 0 === $this->premium;
- 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
copy($langFile, 'languages/' . $prefix . '/' . $this->name . '.json');
- 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 bool
- 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
* @param mixed id or name of the module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (class_exists($modulename)) {
- 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\Db::getInstance()->createCommand()->update('vtiger_tab', ['presence' => $enableDisable], ['name' => $moduleName])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('moduleTabs', 'all');
- 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
foreach ($replacevars as $key => $value) {
- 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
$menuRecordModel = new \Settings_Menu_Record_Model();
- 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 function isExportable(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
file_put_contents($targetPath, $fileContent);
- 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
* @param mixed $modulename
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fire = $instance->moduleHandler((string) $modulename, (string) $eventType);
- 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
$fileContent = str_replace($key, addslashes($value), $fileContent);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string Module name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($instance && method_exists($instance, 'moduleHandler')) {
- 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
* @param mixed $enableDisable
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fire = self::fireEvent($moduleName, $eventType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Settings_GlobalPermission_Record_Model::recalculate();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menuRecordModel->refreshMenuFiles();
- 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
$instance = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instance;
- 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 static function getClassInstance($modulename)
- 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 = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = self::getClassInstance((string) $modulename);
- 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 1 === $this->customized;
- 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
$instance = new $modulename();
- 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 = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Toggle the module (enable/disable).
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventType = self::EVENT_MODULE_DISABLED;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fire) {
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
\App\Db::getInstance()->createCommand()->update('vtiger_tab', ['presence' => $enableDisable], ['name' => $moduleName])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Module::createModuleMetaFile();
- 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 ($data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new self();
- 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
include_once $filepath;
- 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
* Check if this module is upgradable.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if this module is exportable.
- 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
$langFile = 'languages/' . \App\Language::DEFAULT_LANG . '/' . $this->name . '.json';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($languages as $prefix => $language) {
- 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
$data = Functions::getModuleData($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (false === $enableDisable) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tabId = \App\Module::getModuleId($moduleName);
- Exclude checks
The variable $function_name is not named in camelCase. Open
public function unsetRelatedList($moduleInstance, $label = '', $function_name = 'getRelatedList')
{
if (empty($moduleInstance)) {
return;
}
- 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();
}
}
Source
The method __getNextRelatedListSequence is not named in camelCase. Open
public function __getNextRelatedListSequence()
{
return (new \App\Db\Query())->from('vtiger_relatedlists')->where(['tabid' => $this->id])->max('sequence') + 1;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}