Function getInstance
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getInstance($value, $module = false)
{
$tabId = is_numeric($module) ? $module : \App\Module::getModuleId($module);
$cacheName = $value . '|' . $tabId;
if (\App\Cache::has('BlockInstance', $cacheName)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method delete has a boolean flag argument $recursive, which is a certain sign of a Single Responsibility Principle violation. Open
public function delete($recursive = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getInstance has a boolean flag argument $module, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getInstance($value, $module = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '202', column '18'). Open
$query = (new \App\Db\Query())->from(self::$baseTable);
- 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 '231', column '19'). Open
$blocks = (new \App\Db\Query())->from(self::$baseTable)
- 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 '50', column '15'). Open
return (new \App\Db\Query())->from(self::$baseTable)->where(['tabid' => $this->tabid])->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
The method deleteForModule has a boolean flag argument $recursive, which is a certain sign of a Single Responsibility Principle violation. Open
public static function deleteForModule(ModuleBasic $moduleInstance, $recursive = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class '\App\Cache' in method 'getAllForModule'. Open
$blocks = \App\Cache::get('BlocksForModule', $moduleInstance->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\Log' in method '__delete'. Open
\App\Log::trace('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
The method getInstance uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query->where(['blocklabel' => $value, 'tabid' => $tabId]);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Db' in method 'deleteForModule'. 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
The method save uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ($moduleInstance) {
$this->tabid = $moduleInstance->getId();
$this->module = $moduleInstance;
}
- 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 'getInstance'. Open
if (Utils::isNumber($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\Module' in method 'getInstance'. Open
$tabId = is_numeric($module) ? $module : \App\Module::getModuleId($module);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'getInstance'. Open
$data = \App\Cache::get('BlockInstance', $cacheName);
- 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\Field' in method 'delete'. Open
$fields = Field::getAllForBlock($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\Log' in method '__create'. Open
\App\Log::trace("Creating Block $this->label ... 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 '__create'. Open
\App\Log::trace("Module language entry for $this->label ... CHECK", __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 'getInstance'. Open
if (\App\Cache::has('BlockInstance', $cacheName)) {
- 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 getAllForModule uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$blocks = (new \App\Db\Query())->from(self::$baseTable)
->where(['tabid' => $moduleInstance->id])
->orderBy(['sequence' => SORT_ASC])
->all();
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Cache' in method 'getAllForModule'. Open
\App\Cache::save('BlocksForModule', $moduleInstance->id, $blocks);
- 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 '__create'. 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 '__delete'. Open
\App\Log::trace("Deleting Block $this->label ... ", __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
The method getInstance uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query = (new \App\Db\Query())->from(self::$baseTable);
if (Utils::isNumber($value)) {
$query->where(['blockid' => $value]);
} else {
- 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\Field' in method 'deleteForModule'. Open
Field::deleteForModule($moduleInstance);
- 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 'getInstance'. Open
\App\Cache::save('BlockInstance', $cacheName, $data);
- 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 'getAllForModule'. Open
if (\App\Cache::has('BlocksForModule', $moduleInstance->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\Log' in method 'deleteForModule'. Open
\App\Log::trace('Deleting blocks for module ... 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 '__update'. Open
\App\Log::trace("Updating Block {$this->label} [tabId:{$this->tabid}] ... 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\Module' in method 'initialize'. Open
$this->module = Module::getInstance($this->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 "visible" 3 times. Open
$this->visible = $valuemap['visible'] ?? $this->visible ?? 0;
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "detail_view" 3 times. Open
$this->indetailview = $valuemap['detail_view'] ?? $this->indetailview ?? 0;
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "show_title" 3 times. Open
$this->showtitle = $valuemap['show_title'] ?? $this->showtitle ?? null;
- 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" 7 times. Open
return (new \App\Db\Query())->from(self::$baseTable)->where(['tabid' => $this->tabid])->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 "iscustom" 3 times. Open
$this->iscustom = $valuemap['iscustom'] ?? $this->iscustom ?? null;
- 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 "blockid" 4 times. Open
$this->id = $valuemap['blockid'] ?? $this->id ?? null;
- 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 "display_status" 3 times. Open
$this->display_status = $valuemap['display_status'] ?? $this->display_status ?? null;
- 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 "BlocksForModule" 3 times. Open
if (\App\Cache::has('BlocksForModule', $moduleInstance->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 "create_view" 3 times. Open
$this->increateview = $valuemap['create_view'] ?? $this->increateview ?? 0;
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "edit_view" 3 times. Open
$this->ineditview = $valuemap['edit_view'] ?? $this->ineditview ?? 0;
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "blocklabel" 4 times. Open
$this->label = $valuemap['blocklabel'] ?? $this->label ?? null;
- 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" 5 times. Open
return (new \App\Db\Query())->from(self::$baseTable)->where(['tabid' => $this->tabid])->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 "BlockInstance" 3 times. Open
if (\App\Cache::has('BlockInstance', $cacheName)) {
- 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 method trace
from undeclared class \App\Log
Open
\App\Log::trace('DONE', __METHOD__);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new \App\Db\Query())->from(self::$baseTable);
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param int|string block id or block label':
after int|string,
did not see an element name (will guess based on comment order) Open
* @param int|string block id or block label
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete(self::$baseTable, ['tabid' => $tabId])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
return (new \App\Db\Query())->from(self::$baseTable)->where(['tabid' => $this->tabid])->max('sequence') + 1;
- Exclude checks
Return type of addField()
is undeclared type \vtlib\Reference
Open
public function addField(FieldBasic $fieldInstance)
- Exclude checks
Argument 2 (key)
is false
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
if (\App\Cache::has('BlocksForModule', $moduleInstance->id)) {
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$blocks = (new \App\Db\Query())->from(self::$baseTable)
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param Module Instance of the module to which this block is associated':
after Module,
did not see an element name (will guess based on comment order) Open
* @param Module Instance of the module to which this block is associated
- Exclude checks
Returning type array<int>|array{}</int>
but getAllForModule()
is declared to return \vtlib\Block
Open
return $instances;
- Exclude checks
Doc-block of $moduleInstance
in save
contains phpdoc param type mixed
which is incompatible with the param type ?\vtlib\ModuleBasic
declared in the signature Open
* @param mixed $moduleInstance
- Exclude checks
Call with 1 arg(s) to \vtlib\Field::delete()
which only takes 0 arg(s) defined at /code/vtlib/Vtiger/FieldBasic.php:316
Open
$fieldInstance->delete($recursive);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert(self::$baseTable, [
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->delete(self::$baseTable, ['blockid' => $this->id])->execute();
- Exclude checks
Expected @param annotation for value
to be before the @param annotation for module
Open
* @param mixed $module Mixed id or name of the module
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Deleting Block $this->label ... ", __METHOD__);
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param bool True to delete associated fields, False to avoid it':
after bool,
did not see an element name (will guess based on comment order) Open
* @param bool True to delete associated fields, False to avoid it
- Exclude checks
Argument 2 (key)
is false
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
$blocks = \App\Cache::get('BlocksForModule', $moduleInstance->id);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Updating Block {$this->label} [tabId:{$this->tabid}] ... DONE", __METHOD__);
- Exclude checks
Return type of getInstance()
is undeclared type \self
Open
public static function getInstance($value, $module = false)
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_module_dashboard_blocks', ['tabid' => $tabId])->execute();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Module language entry for $this->label ... CHECK", __METHOD__);
- Exclude checks
Argument 2 (key)
is false
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
\App\Cache::save('BlocksForModule', $moduleInstance->id, $blocks);
- Exclude checks
Saw an @param annotation for module,
but it was not found in the param list of function initialize(mixed $valuemap)
Open
* @param mixed $module Mixed id or name of the module
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param bool true to delete associated fields, false otherwise':
after bool,
did not see an element name (will guess based on comment order) Open
* @param bool true to delete associated fields, false otherwise
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Deleting blocks for module ... DONE', __METHOD__);
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param array Map of column name and value':
after array,
did not see an element name (will guess based on comment order) Open
* @param array Map of column name and value
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Creating Block $this->label ... DONE", __METHOD__);
- Exclude checks
Returning type \vtlib\Block
but addField()
is declared to return \vtlib\Reference
Open
return $this;
- Exclude checks
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 property $display_status is not named in camelCase. Open
class Block
{
/** ID of this block instance */
public $id;
/** Tab id */
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
public $id;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
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
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Tab id */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $baseTable = 'vtiger_blocks';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** ID of this block instance */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $label;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $indetailview = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $iscustom = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $sequence;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $visible = 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $icon;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Label for this block instance */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $increateview = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $display_status = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $showtitle = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $ineditview = 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
'visible' => $this->visible,
- 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 __delete()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \App\Db\Query())->from(self::$baseTable)->where(['tabid' => $this->tabid])->max('sequence') + 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $module Mixed id or name of the module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->iscustom = $valuemap['iscustom'] ?? $this->iscustom ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
], ['blockid' => $this->id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Deleting Block $this->label ... ", __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 function __getNextSequence()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->id = $valuemap['blockid'] ?? $this->id ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tabid' => $this->tabid,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'blocklabel' => $this->label,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'visible' => $this->visible,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'display_status' => $this->display_status,
- 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
'edit_view' => $this->ineditview,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __update()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()
- 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
$this->label = $valuemap['blocklabel'] ?? $this->label ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->update(self::$baseTable, [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Create vtiger CRM block.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function save(?ModuleBasic $moduleInstance = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'create_view' => $this->increateview,
- 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("Creating Block $this->label ... DONE", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool True to delete associated fields, False to avoid it
- 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
* Add field to this block.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'show_title' => $this->showtitle,
- 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 array Map of column name and 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
public static function getInstance($value, $module = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function delete($recursive = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->sequence) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sequence' => $this->sequence,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($recursive) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fields as $fieldInstance) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'create_view' => $this->increateview,
- 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 block.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'detail_view' => $this->indetailview,
- 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->__create();
- 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
$tabId = is_numeric($module) ? $module : \App\Module::getModuleId($module);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->id = $db->getLastInsertID(self::$baseTable . '_blockid_seq');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'edit_view' => $this->ineditview,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'iscustom' => $this->iscustom,
- 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\Db::getInstance()->createCommand()->delete(self::$baseTable, ['blockid' => $this->id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $valuemap
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Save this block 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
}
- 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 $recursive
- 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
if ($this->id) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__update();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->module = $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
* @return Reference to this block 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 function addField(FieldBasic $fieldInstance)
- 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 = \App\Cache::get('BlockInstance', $cacheName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get next sequence value to use for this block 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
$this->display_status = $valuemap['display_status'] ?? $this->display_status ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->tabid = $moduleInstance->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Delete block 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
* @return \self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $tabid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $module;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Basic table name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __create()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->display_status = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'detail_view' => $this->indetailview,
- 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
'blocklabel' => $this->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
\App\Log::trace('DONE', __METHOD__);
- 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
$fields = Field::getAllForBlock($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->save($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Cache::has('BlockInstance', $cacheName)) {
- 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 initialize($valuemap)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->indetailview = $valuemap['detail_view'] ?? $this->indetailview ?? 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Module Instance of the module to which this block is associated
- 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
if ($moduleInstance) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Initialize this block instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->sequence = $valuemap['sequence'] ?? $this->sequence ?? 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
'display_status' => $this->display_status,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'icon' => $this->icon,
- 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("Updating Block {$this->label} [tabId:{$this->tabid}] ... DONE", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->showtitle = $valuemap['show_title'] ?? $this->showtitle ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->module = Module::getInstance($this->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
'show_title' => $this->showtitle,
- 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
'icon' => $this->icon,
- 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
$this->tabid = $valuemap['tabid'] ?? $this->tabid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->increateview = $valuemap['create_view'] ?? $this->increateview ?? 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
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sequence' => $this->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
$fieldInstance->delete($recursive);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__delete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param FieldBasic $fieldInstance
- 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
$this->ineditview = $valuemap['edit_view'] ?? $this->ineditview ?? 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
if (0 != $this->display_status) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert(self::$baseTable, [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Module language entry for $this->label ... CHECK", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Delete this 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|string block id or block label
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cacheName = $value . '|' . $tabId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->visible = $valuemap['visible'] ?? $this->visible ?? 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->icon = $valuemap['icon'] ?? $this->icon ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->sequence = $this->__getNextSequence();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'iscustom' => $this->iscustom,
- 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 $module Mixed id or name of the module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->where(['blockid' => $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
->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
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::save('BlockInstance', $cacheName, $data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instances = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instances[] = $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Delete all blocks associated with module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param ModuleBasic $moduleInstance
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get all block instances associated with the module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blocks = \App\Cache::get('BlocksForModule', $moduleInstance->id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->orderBy(['sequence' => SORT_ASC])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instances;
- 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
->where(['tabid' => $moduleInstance->id])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete(self::$baseTable, ['tabid' => $tabId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->where(['blocklabel' => $value, 'tabid' => $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
public static function deleteForModule(ModuleBasic $moduleInstance, $recursive = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->from(self::$baseTable);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $query->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::save('BlocksForModule', $moduleInstance->id, $blocks);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($blocks as $row) {
- 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
$instance->initialize($row);
- 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
{
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool true to delete associated fields, false otherwise
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Field::deleteForModule($moduleInstance);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_module_dashboard_blocks', ['tabid' => $tabId])->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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($recursive) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tabId = $moduleInstance->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param ModuleBasic $moduleInstance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $recursive
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Utils::isNumber($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
$instance = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAllForModule(ModuleBasic $moduleInstance)
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('Deleting blocks for module ... DONE', __METHOD__);
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Cache::has('BlocksForModule', $moduleInstance->id)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blocks = (new \App\Db\Query())->from(self::$baseTable)
- Exclude checks
The method __getNextSequence is not named in camelCase. Open
public function __getNextSequence()
{
return (new \App\Db\Query())->from(self::$baseTable)->where(['tabid' => $this->tabid])->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() {
}
}
Source
The method __create is not named in camelCase. Open
public function __create()
{
$db = \App\Db::getInstance();
if (!$this->sequence) {
$this->sequence = $this->__getNextSequence();
- 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() {
}
}
Source
The method __update is not named in camelCase. Open
public function __update()
{
\App\Db::getInstance()
->createCommand()
->update(self::$baseTable, [
- 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() {
}
}
Source
The method __delete is not named in camelCase. Open
public function __delete()
{
\App\Log::trace("Deleting Block $this->label ... ", __METHOD__);
\App\Db::getInstance()->createCommand()->delete(self::$baseTable, ['blockid' => $this->id])->execute();
\App\Log::trace('DONE', __METHOD__);
- 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() {
}
}