YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/models/Block.php

Summary

Maintainability
A
35 mins
Test Coverage
F
48%

Function getInActiveFields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getInActiveFields($raw = true)
    {
        $inActiveFields = [];
        foreach ($this->getFields() as $fieldName => $fieldModel) {
            if (!$fieldModel->isActiveField()) {
Severity: Minor
Found in modules/Vtiger/models/Block.php - About 35 mins to fix

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

Missing class import via use statement (line '225', column '49').
Open

            ->update('vtiger_blocks', ['sequence' => new yii\db\Expression('sequence + 1')], ['and', ['>', 'sequence', $fromSequence], ['tabid' => $sourceModuleTabId]])
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 '238', column '15').
Open

        return (new App\Db\Query())->select(['blockid', 'sequence'])
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 '198', column '68').
Open

        $db->createCommand()->update('vtiger_blocks', ['sequence' => new yii\db\Expression($case)], ['blockid' => array_keys($sequenceList)])
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 '255', column '15').
Open

        return (new \App\Db\Query())->from('vtiger_blocks')->where(['blocklabel' => $blockLabel, 'tabid' => $tabId])->exists();
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 getInstance has a boolean flag argument $moduleInstance, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function getInstance($value, $moduleInstance = false)
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 getInActiveFields has a boolean flag argument $raw, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getInActiveFields($raw = true)
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 '211', column '15').
Open

        return (new App\Db\Query())->from('vtiger_field')
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid assigning values to variables in if clauses and the like (line '146', column '7').
Open

    public static function getAllForModule(vtlib\ModuleBasic $moduleModel)
    {
        $blockModelList = [];
        if ($blockObjects = parent::getAllForModule($moduleModel)) {
            foreach ($blockObjects as $blockObject) {
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

The method getInActiveFields uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $fieldDetails = $fieldModel->getFieldInfo();
                    $fieldDetails['fieldid'] = $fieldModel->getId();
                    $inActiveFields[$fieldName] = $fieldDetails;
                }
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 'Vtiger_Loader' in method 'getInstanceFromBlockObject'.
Open

        $blockClassName = Vtiger_Loader::getComponentClassName('Model', 'Block', $blockObject->module->name);
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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_Field_Model' in method 'getFields'.
Open

            $moduleFields = Vtiger_Field_Model::getAllForModule($this->module);
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 'updateSequenceNumber'.
Open

        $db = App\Db::getInstance();
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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 "display_status" 3 times.
Open

            ->update('vtiger_blocks', ['blocklabel' => $this->label, 'display_status' => $this->display_status], ['blockid' => $this->id])
Severity: Critical
Found in modules/Vtiger/models/Block.php by sonar-php

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" 3 times.
Open

            ->update('vtiger_blocks', ['blocklabel' => $this->label, 'display_status' => $this->display_status], ['blockid' => $this->id])
Severity: Critical
Found in modules/Vtiger/models/Block.php by sonar-php

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" 4 times.
Open

        $db->createCommand()->update('vtiger_blocks', ['sequence' => new yii\db\Expression($case)], ['blockid' => array_keys($sequenceList)])
Severity: Critical
Found in modules/Vtiger/models/Block.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "tabid" 3 times.
Open

            ->update('vtiger_blocks', ['sequence' => new yii\db\Expression('sequence + 1')], ['and', ['>', 'sequence', $fromSequence], ['tabid' => $sourceModuleTabId]])
Severity: Critical
Found in modules/Vtiger/models/Block.php by sonar-php

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_blocks" 5 times.
Open

            ->update('vtiger_blocks', ['blocklabel' => $this->label, 'display_status' => $this->display_status], ['blockid' => $this->id])
Severity: Critical
Found in modules/Vtiger/models/Block.php by sonar-php

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.

Suspicious array access to false
Open

                $this->fields[$field->get('name')] = $field;
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Parameter $raw has undeclared type \type
Open

    public function getInActiveFields($raw = true)
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Assigning array{} to property but \Vtiger_Block_Model->fields is false
Open

            $this->fields = [];
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Argument 3 (moduleName) is false but \Vtiger_Loader::getComponentClassName() takes string defined at /code/include/Loader.php:149
Open

        $blockClassName = Vtiger_Loader::getComponentClassName('Model', 'Block', $blockObject->module->name);
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Call to undeclared method \App\Db::quoteValue
Open

            $case .= " WHEN {$db->quoteValue($blockId)} THEN {$db->quoteValue($sequence)}";
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Assigning array<string></string> to property but \Vtiger_Block_Model->fields is false
Open

        $this->fields = $fieldModelList;
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Assigning \Vtiger_Field_Model[] to property but \Vtiger_Block_Model->fields is false
Open

                $this->fields[$field->get('name')] = $field;
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Call to method __construct from undeclared class \yii\db\Expression
Open

        $db->createCommand()->update('vtiger_blocks', ['sequence' => new yii\db\Expression($case)], ['blockid' => array_keys($sequenceList)])
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Assigning array|null[] to property but \Vtiger_Block_Model->fields is false
Open

        $this->fields = $fieldModelList;
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Default value for \type $raw can't be true
Open

    public function getInActiveFields($raw = true)
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Call to undeclared method \App\Db::createCommand
Open

        App\Db::getInstance()->createCommand()
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Call to undeclared method \App\Db::createCommand
Open

        App\Db::getInstance()->createCommand()
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Call to undeclared method \App\Db\Query::from
Open

        return (new \App\Db\Query())->from('vtiger_blocks')->where(['blocklabel' => $blockLabel, 'tabid' => $tabId])->exists();
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Class \vtlib\Block was passed to foreach, but it does not extend Traversable. This may be intentional, because some of that class's declared properties are accessible from this context. (This check excludes dynamic properties)
Open

            foreach ($blockObjects as $blockObject) {
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Saw possibly unextractable annotation for a fragment of comment '* @param number ModuleId': after number, did not see an element name (will guess based on comment order)
Open

     * @param number ModuleId
Severity: Info
Found in modules/Vtiger/models/Block.php by phan

Saw unextractable annotation for comment '* @return <object>'</object>
Open

     * @return <Object>
Severity: Info
Found in modules/Vtiger/models/Block.php by phan

Return type of getInActiveFields() is undeclared type \type
Open

    public function getInActiveFields($raw = true)
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Call to undeclared method \App\Db::createCommand
Open

        $db->createCommand()->update('vtiger_blocks', ['sequence' => new yii\db\Expression($case)], ['blockid' => array_keys($sequenceList)])
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Call to undeclared method \App\Db\Query::from
Open

        return (new App\Db\Query())->from('vtiger_field')
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Call to method __construct from undeclared class \yii\db\Expression
Open

            ->update('vtiger_blocks', ['sequence' => new yii\db\Expression('sequence + 1')], ['and', ['>', 'sequence', $fromSequence], ['tabid' => $sourceModuleTabId]])
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Returning type \Vtiger_Field_Model[]|array[]|array{fieldid:int}[]|array{} but getInActiveFields() is declared to return \type
Open

        return $inActiveFields;
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Declaration of function getAllForModule(\vtlib\ModuleBasic $moduleModel) : \Vtiger_Block_Model[] should be compatible with function getAllForModule(\vtlib\ModuleBasic $moduleInstance) : \vtlib\Block defined in /code/vtlib/Vtiger/Block.php:226
Open

    public static function getAllForModule(vtlib\ModuleBasic $moduleModel)
Severity: Minor
Found in modules/Vtiger/models/Block.php by phan

Call to undeclared method \App\Db\Query::select
Open

        return (new App\Db\Query())->select(['blockid', 'sequence'])
Severity: Critical
Found in modules/Vtiger/models/Block.php by phan

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Vtiger_Block_Model extends vtlib\Block

The class Vtiger_Block_Model is not named in CamelCase.
Open

class Vtiger_Block_Model extends vtlib\Block
{
    public $fields = false;

    /**
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = App\Db::getInstance();
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        return 0 !== (int) $this->iscustom;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        if (0 === (int) $this->get('display_status')) {

Spaces must be used to indent lines; tabs are not allowed
Open

            return true;

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($this->getFields() as $fieldName => $fieldModel) {

Spaces must be used to indent lines; tabs are not allowed
Open

                $this->fields[$field->get('name')] = $field;

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function which indicates whether the block is shown or hidden.

Spaces must be used to indent lines; tabs are not allowed
Open

        return false;

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $inActiveFields = [];

Spaces must be used to indent lines; tabs are not allowed
Open

                } else {

Spaces must be used to indent lines; tabs are not allowed
Open

    public $fields = false;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            $this->fields = [];

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->fields;

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->fields = $fieldModelList;

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get the value of a given property.

Spaces must be used to indent lines; tabs are not allowed
Open

        if (property_exists($this, $propertyName)) {

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

            return $this->{$propertyName};

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return type - arrays

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getInActiveFields($raw = true)

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check if block is customizable.

Spaces must be used to indent lines; tabs are not allowed
Open

        if (2 === (int) $this->get('display_status')) {

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

                $moduleFields[$this->id] = [];

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        if (property_exists($this, $propertyName)) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get fields.

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param type $raw - true to send field in model format or false to send in array format

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getFields()

Spaces must be used to indent lines; tabs are not allowed
Open

            // if block does not contains any fields

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    public function get($propertyName)

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    public function setFields($fieldModelList)

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;

Spaces must be used to indent lines; tabs are not allowed
Open

    public function set($propertyName, $value)

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isCustomized()

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function __update()

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isHidden()

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isDynamic()

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

                    $fieldDetails = $fieldModel->getFieldInfo();

Spaces must be used to indent lines; tabs are not allowed
Open

                if ($raw) {

Spaces must be used to indent lines; tabs are not allowed
Open

                    $inActiveFields[$fieldName] = $fieldModel;

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        App\Db::getInstance()->createCommand()

Spaces must be used to indent lines; tabs are not allowed
Open

            ->execute();

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                    $fieldDetails['fieldid'] = $fieldModel->getId();

Spaces must be used to indent lines; tabs are not allowed
Open

            if (!isset($moduleFields[$this->id])) {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function which indicates whether the block is dynamic show.

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get the in active fields for the block.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return Vtiger_Field_Model[]|false

Spaces must be used to indent lines; tabs are not allowed
Open

            foreach ($moduleFields[$this->id] as &$field) {

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        $blockModel = new $blockClassName();

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        $db->createCommand()->update('vtiger_blocks', ['sequence' => new yii\db\Expression($case)], ['blockid' => array_keys($sequenceList)])

Spaces must be used to indent lines; tabs are not allowed
Open

        return (new App\Db\Query())->from('vtiger_field')

Spaces must be used to indent lines; tabs are not allowed
Open

        App\Db::getInstance()->createCommand()

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get number sequence of blocks.

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param vtlib\ModuleBasic $moduleModel - module instance

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return self

Spaces must be used to indent lines; tabs are not allowed
Open

            $blockModel->{$properName} = $propertyValue;

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function updateSequenceNumber($sequenceList)

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Line exceeds 120 characters; contains 138 characters
Open

            ->update('vtiger_blocks', ['blocklabel' => $this->label, 'display_status' => $this->display_status], ['blockid' => $this->id])

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

                $blockModelList[] = self::getInstanceFromBlockObject($blockObject);

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            ->execute();

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to push all blocks down after sequence number.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $blockLabel

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        if (empty($this->fields)) {

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return <Object>

Spaces must be used to indent lines; tabs are not allowed
Open

     * Update block.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

        return false;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getAllForModule(vtlib\ModuleBasic $moduleModel)

Spaces must be used to indent lines; tabs are not allowed
Open

        return $blockModelList;

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get block instance.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int[] $sequenceList

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

            ->from('vtiger_blocks')

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($objectProperties as $properName => $propertyValue) {

Spaces must be used to indent lines; tabs are not allowed
Open

            $case .= " WHEN {$db->quoteValue($blockId)} THEN {$db->quoteValue($sequence)}";

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $propertyName

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            return true;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            if (!$fieldModel->isActiveField()) {

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

        $blockClassName = Vtiger_Loader::getComponentClassName('Model', 'Block', $blockObject->module->name);

Spaces must be used to indent lines; tabs are not allowed
Open

        return $blockModel;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $fromSequence

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $moduleTabId

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            $moduleFields = Vtiger_Field_Model::getAllForModule($this->module);

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            $this->{$propertyName} = $value;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

            ->update('vtiger_blocks', ['blocklabel' => $this->label, 'display_status' => $this->display_status], ['blockid' => $this->id])

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        return $inActiveFields;

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($sequenceList as $blockId => $sequence) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function checkFieldsExists($blockId)

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $sourceModuleTabId

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function pushDown($fromSequence, $sourceModuleTabId)

Spaces must be used to indent lines; tabs are not allowed
Open

            ->update('vtiger_blocks', ['sequence' => new yii\db\Expression('sequence + 1')], ['and', ['>', 'sequence', $fromSequence], ['tabid' => $sourceModuleTabId]])

Spaces must be used to indent lines; tabs are not allowed
Open

            ->createCommand()->queryAllByGroup(0);

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to check whether duplicate exist or not.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Line exceeds 120 characters; contains 127 characters
Open

        return (new \App\Db\Query())->from('vtiger_blocks')->where(['blocklabel' => $blockLabel, 'tabid' => $tabId])->exists();

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        return self::getInstanceFromBlockObject(parent::getInstance($value, $moduleInstance));

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to retrieve block instance from vtlib\Block object.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getAllBlockSequenceList($moduleTabId)

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function checkDuplicate($blockLabel, $tabId)

Spaces must be used to indent lines; tabs are not allowed
Open

                }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getInstance($value, $moduleInstance = false)

Spaces must be used to indent lines; tabs are not allowed
Open

        $objectProperties = get_object_vars($blockObject);

Spaces must be used to indent lines; tabs are not allowed
Open

            ->where(['block' => $blockId])

Spaces must be used to indent lines; tabs are not allowed
Open

            ->execute();

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            ->where(['tabid' => $moduleTabId])

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param mixed $tabId

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return Vtiger_Block_Model[] List of Vtiger_Block_Model

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check if fields are in block.

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $blockId

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($blockObjects = parent::getAllForModule($moduleModel)) {

Spaces must be used to indent lines; tabs are not allowed
Open

        $case = ' CASE blockid ';

Line exceeds 120 characters; contains 141 characters
Open

        $db->createCommand()->update('vtiger_blocks', ['sequence' => new yii\db\Expression($case)], ['blockid' => array_keys($sequenceList)])

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

                    $inActiveFields[$fieldName] = $fieldDetails;

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            foreach ($blockObjects as $blockObject) {

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param vtlib\ModuleBasic|bool $moduleInstance

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        return (new App\Db\Query())->select(['blockid', 'sequence'])

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return Vtiger_Block_Model

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getInstanceFromBlockObject(vtlib\Block $blockObject)

Spaces must be used to indent lines; tabs are not allowed
Open

            ->exists();

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $blockModelList = [];

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int|string             $value

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param vtlib\Block $blockObject - vtlib block object

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $db = App\Db::getInstance();

Spaces must be used to indent lines; tabs are not allowed
Open

        $case .= ' END';

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param number ModuleId

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool true/false

Spaces must be used to indent lines; tabs are not allowed
Open

        return (new \App\Db\Query())->from('vtiger_blocks')->where(['blocklabel' => $blockLabel, 'tabid' => $tabId])->exists();

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to retrieve block instances for a module.

Spaces must be used to indent lines; tabs are not allowed
Open

     * Update sequence number of blocks.

Line exceeds 120 characters; contains 168 characters
Open

            ->update('vtiger_blocks', ['sequence' => new yii\db\Expression('sequence + 1')], ['and', ['>', 'sequence', $fromSequence], ['tabid' => $sourceModuleTabId]])

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Class name "Vtiger_Block_Model" is not in camel caps format
Open

class Vtiger_Block_Model extends vtlib\Block

The method __update is not named in camelCase.
Open

    public function __update()
    {
        App\Db::getInstance()->createCommand()
            ->update('vtiger_blocks', ['blocklabel' => $this->label, 'display_status' => $this->display_status], ['blockid' => $this->id])
            ->execute();
Severity: Minor
Found in modules/Vtiger/models/Block.php by phpmd

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

There are no issues that match your filters.

Category
Status