YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Widgets/models/Module.php

Summary

Maintainability
B
5 hrs
Test Coverage
F
10%

The class Settings_Widgets_Module_Model has an overall complexity of 54 which is very high. The configured complexity threshold is 50.
Open

class Settings_Widgets_Module_Model extends Settings_Vtiger_Module_Model
{
    /**
     * Function to get widgets.
     *

Function getType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function getType($module = false)
    {
        $moduleModel = Vtiger_Module_Model::getInstance($module);
        if (\App\Config::performance('LOAD_CUSTOM_FILES')) {
            $loader[] = "custom/modules/{$moduleModel->getName()}/widgets/";
Severity: Minor
Found in modules/Settings/Widgets/models/Module.php - About 1 hr 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

Method saveWidget has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function saveWidget($params)
    {
        $db = App\Db::getInstance();
        $tabid = $params['tabid'];
        $data = $params['data'];
Severity: Minor
Found in modules/Settings/Widgets/models/Module.php - About 1 hr to fix

    Function saveWidget has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function saveWidget($params)
        {
            $db = App\Db::getInstance();
            $tabid = $params['tabid'];
            $data = $params['data'];
    Severity: Minor
    Found in modules/Settings/Widgets/models/Module.php - About 25 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

    Function getHeaderSwitch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getHeaderSwitch($sourceModule, $index = [])
        {
            $data = [];
            $moduleName = is_numeric($sourceModule) ? \App\Module::getModuleName($sourceModule) : $sourceModule;
            foreach (\App\Relation::getByModule($moduleName) as $moduleData) {
    Severity: Minor
    Found in modules/Settings/Widgets/models/Module.php - About 25 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

    Function getFiletrs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getFiletrs(array $modules): array
        {
            $filetrs = $tabid = [];
            foreach ($modules as $value) {
                if (!\in_array($value['related_tabid'], $tabid)) {
    Severity: Minor
    Found in modules/Settings/Widgets/models/Module.php - About 25 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

    Function getCheckboxs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getCheckboxs(array $modules): array
        {
            $checkBoxs = [];
            $tabid = [];
            foreach ($modules as $value) {
    Severity: Minor
    Found in modules/Settings/Widgets/models/Module.php - About 25 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

    The method getType() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
    Open

        public function getType($module = false)
        {
            $moduleModel = Vtiger_Module_Model::getInstance($module);
            if (\App\Config::performance('LOAD_CUSTOM_FILES')) {
                $loader[] = "custom/modules/{$moduleModel->getName()}/widgets/";

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

    The class Settings_Widgets_Module_Model has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
    Open

    class Settings_Widgets_Module_Model extends Settings_Vtiger_Module_Model
    {
        /**
         * Function to get widgets.
         *

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    The method getType has a boolean flag argument $module, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getType($module = false)

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

        public function getFields($tabid, $uitype = false)

    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 '158', column '24').
    Open

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])

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

            return (new \App\Db\Query())->from('vtiger_widgets')->where(['tabid' => $tabid])->max('sequence');

    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 '184', column '17').
    Open

            $query = (new \App\Db\Query())->select(['fieldid', 'columnname', 'tablename', 'fieldname', 'fieldlabel'])

    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 '271', column '21').
    Open

            $resultrow = (new \App\Db\Query())->from('vtiger_widgets')

    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 '131', column '24').
    Open

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])

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

        public static function getWidgets($module = false)

    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 '319', column '22').
    Open

            $dataReader = (new \App\Db\Query())->select(['fieldlabel', 'fieldname'])

    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 '29', column '17').
    Open

            $query = (new App\Db\Query())->from('vtiger_widgets');

    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 '94', column '18').
    Open

                foreach ((new \DirectoryIterator($dir)) as $fileInfo) {

    MissingImport

    Since: 2.7.0

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

    Example

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

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

    Avoid using static access to class '\App\Language' in method 'getCheckboxs'.
    Open

                        $checkBoxs[$value['related_tabid']][$row['tablename'] . '.' . $row['fieldname']] = \App\Language::translate($row['fieldlabel'], $value['related_modulename']);

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

            \App\Cache::clear();

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class '\App\Language' in method 'getWYSIWYGFields'.
    Open

                $field[$row['fieldname']] = \App\Language::translate($row['fieldlabel'], $module);

    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 assigning values to variables in if clauses and the like (line '345', column '9').
    Open

        public static function getHeaderSwitch($sourceModule, $index = [])
        {
            $data = [];
            $moduleName = is_numeric($sourceModule) ? \App\Module::getModuleName($sourceModule) : $sourceModule;
            foreach (\App\Relation::getByModule($moduleName) as $moduleData) {

    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

    Avoid using static access to class '\App\RecordStatus' in method 'getHeaderSwitch'.
    Open

                if (($fieldName = \App\RecordStatus::getFieldName($moduleName)) && ($statuses = \App\RecordStatus::getStates($moduleName, \App\RecordStatus::RECORD_STATE_CLOSED))) {

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class '\App\Language' in method 'getFields'.
    Open

                $fieldsNames[$row['fieldname']] = \App\Language::translate($row['fieldlabel'], $moduleName);

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

            \App\Cache::delete('ModuleWidgets', $tabid);

    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\Json' in method 'getWidgets'.
    Open

                $row['data'] = \App\Json::decode($row['data']);

    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_Module_Model' in method 'getType'.
    Open

            $moduleModel = Vtiger_Module_Model::getInstance($module);

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

            $moduleName = App\Module::getModuleName($tabid);

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class '\App\Language' in method 'getFields'.
    Open

                $fieldlabel[$row['fieldid']] = \App\Language::translate($row['fieldlabel'], $moduleName);

    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_Loader' in method 'saveWidget'.
    Open

            $widgetName = Vtiger_Loader::getComponentClassName('Widget', $data['type'], $widgetModuleName);

    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\Json' in method 'saveWidget'.
    Open

            $serializeData = \App\Json::encode($data);

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class '\App\Relation' in method 'getHeaderSwitch'.
    Open

            foreach (\App\Relation::getByModule($moduleName) as $moduleData) {

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

                return \App\Cache::get('ModuleWidgets', $module);

    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_Module_Model' in method 'getModulesList'.
    Open

                $moduleModel = Vtiger_Module_Model::getInstance($module['name']);

    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 saveWidget uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $db->createCommand()->insert('vtiger_widgets', [
                    'tabid' => $tabid,
                    'type' => $type,
                    'label' => $label,

    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\Config' in method 'getType'.
    Open

            if (\App\Config::performance('LOAD_CUSTOM_FILES')) {

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

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

    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 assigning values to variables in if clauses and the like (line '345', column '72').
    Open

        public static function getHeaderSwitch($sourceModule, $index = [])
        {
            $data = [];
            $moduleName = is_numeric($sourceModule) ? \App\Module::getModuleName($sourceModule) : $sourceModule;
            foreach (\App\Relation::getByModule($moduleName) as $moduleData) {

    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

    Avoid using static access to class '\App\Language' in method 'getFiletrs'.
    Open

                        $filetrs[$value['related_tabid']][$row['fieldname']] = \App\Language::translate($row['fieldlabel'], $value['related_modulename']);

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class '\vtlib\Functions' in method 'getModulesList'.
    Open

            $modules = \vtlib\Functions::getAllModules(true, true, 0);

    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\Json' in method 'getWidgetInfo'.
    Open

            $resultrow['data'] = \App\Json::decode($resultrow['data']);

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

                $module = \App\Module::getModuleId($module);

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

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

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class '\App\Language' in method 'getHeaderSwitch'.
    Open

                            'label' => \App\Language::translate('LBL_HEADERSWITCH_OPEN_CLOSED', $moduleName),

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

            App\Cache::save('ModuleWidgets', $module, $widgets);

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class '\App\Language' in method 'getFields'.
    Open

                $fieldsList[$tabid][$row['tablename'] . '::' . $row['columnname'] . '::' . $row['fieldname']] = \App\Language::translate($row['fieldlabel'], $moduleName);

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

            $widgetModuleName = \App\Module::getModuleName($tabid);

    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\RecordStatus' in method 'getHeaderSwitch'.
    Open

                if (($fieldName = \App\RecordStatus::getFieldName($moduleName)) && ($statuses = \App\RecordStatus::getStates($moduleName, \App\RecordStatus::RECORD_STATE_CLOSED))) {

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class '\App\Language' in method 'getCustomView'.
    Open

                    $customView[$module['related_tabid']][$cvId] = \App\Language::translate($cvModel->get('viewname'), $module['related_modulename']);

    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_Loader' in method 'getType'.
    Open

                        $className = Vtiger_Loader::getComponentClassName('Widget', $type, $moduleModel->getName());

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

            $moduleName = is_numeric($sourceModule) ? \App\Module::getModuleName($sourceModule) : $sourceModule;

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

            if (\App\Cache::has('ModuleWidgets', $module)) {

    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 'CustomView_Record_Model' in method 'getCustomView'.
    Open

                foreach (CustomView_Record_Model::getAll($module['related_modulename']) as $cvId => $cvModel) {

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

            \App\Cache::delete('ModuleWidgets', $tabid);

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

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])

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

            if (isset($data['FastEdit'])) {

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

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

    Define a constant instead of duplicating this literal "related_tabid" 10 times.
    Open

                if (!\in_array($value['related_tabid'], $tabid)) {

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

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])

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

                        ->from('vtiger_field')

    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

            $dataReader = $query->orderBy(['tabid' => SORT_ASC, 'sequence' => SORT_ASC])

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

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

    Define a constant instead of duplicating this literal "label" 5 times.
    Open

            $label = $data['label'] ?? '';

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

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])

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

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])

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

            $query = (new App\Db\Query())->from('vtiger_widgets');

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

                $query->where(['tabid' => $module]);

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

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

    Define a constant instead of duplicating this literal "related_modulename" 5 times.
    Open

                        $filetrs[$value['related_tabid']][$row['fieldname']] = \App\Language::translate($row['fieldlabel'], $value['related_modulename']);

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

            if (\App\Cache::has('ModuleWidgets', $module)) {

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

                        ->where(['tabid' => $value['related_tabid'], 'uitype' => [15, 16]])

    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.

    Invalid offset 0 of array type array{}
    Open

            if (isset($data[$index[0]][$index[1]])) {

    Invalid offset 1 of array type array{}
    Open

                return $data[$index[0]][$index[1]];

    Default value for int $module can't be false
    Open

        public function getType($module = false)

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

                        $className = Vtiger_Loader::getComponentClassName('Widget', $type, $moduleModel->getName());

    Argument 1 (arr1) is null but \array_merge() takes array
    Open

            $data = array_merge($dbParams, $data);

    When fetching an array index from a value of type array{0:array{type:1,label:string,value:array<string>}},</string> found an array index of type null, but expected the index to be of the non-nullable type int
    Open

                return $data[$index[0]][$index[1]];

    Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
    Open

            $loader[] = "modules/{$moduleModel->getName()}/widgets/";

    Returning type array|array{data:mixed} but getWidgetInfo() is declared to return \type
    Open

            return $resultrow;

    Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
    Open

                $loader[] = "custom/modules/{$moduleModel->getName()}/widgets/";

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

                $db->createCommand()->update('vtiger_widgets', [
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

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

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

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

            \App\Db::getInstance()->createCommand()->delete('vtiger_widgets', ['id' => $wid])->execute();
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

    Invalid offset 0 of array type array{}
    Open

                return $data[$index[0]][$index[1]];

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

            $query = (new \App\Db\Query())->select(['fieldid', 'columnname', 'tablename', 'fieldname', 'fieldlabel'])
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

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

                $db->createCommand()->insert('vtiger_widgets', [
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

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

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

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

        public function getWidgetInfo($wid)

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

            $query = (new App\Db\Query())->from('vtiger_widgets');
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

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

            $dataReader = (new \App\Db\Query())->select(['fieldlabel', 'fieldname'])
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

    When fetching an array index from a value of type array{0:array{type:1,label:string,value:array<string>}}[]|array{},</string> found an array index of type null, but expected the index to be of the non-nullable type int|string
    Open

                return $data[$index[0]][$index[1]];

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

            $resultrow = (new \App\Db\Query())->from('vtiger_widgets')
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

    Default value for int|string $module can't be false
    Open

        public static function getWidgets($module = false)

    Variable $loader was undeclared, but array fields are being added to it.
    Open

                $loader[] = "custom/modules/{$moduleModel->getName()}/widgets/";

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

            return (new \App\Db\Query())->from('vtiger_widgets')->where(['tabid' => $tabid])->max('sequence');
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

    Invalid offset 1 of array type array{}
    Open

            if (isset($data[$index[0]][$index[1]])) {

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

                $db->createCommand()
    Severity: Critical
    Found in modules/Settings/Widgets/models/Module.php by phan

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

    class Settings_Widgets_Module_Model extends Settings_Vtiger_Module_Model

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

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

    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 class Settings_Widgets_Module_Model is not named in CamelCase.
    Open

    class Settings_Widgets_Module_Model extends Settings_Vtiger_Module_Model
    {
        /**
         * Function to get widgets.
         *

    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();

    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

        public static function getWidgets($module = 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

            if ($module && !is_numeric($module)) {

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

                $module = \App\Module::getModuleId($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

         * Function to get widgets.

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

         * @param int|string $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

        /**

    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

                $widgets[$row['wcol']][$row['id']] = $row;

    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 int[]

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

            $checkBoxs = [];

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

                    while ($row = $dataReader->read()) {

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

        public function getFields($tabid, $uitype = false)

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

                $fieldsNames[$row['fieldname']] = \App\Language::translate($row['fieldlabel'], $moduleName);

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

                $fieldlabel[$row['fieldid']] = \App\Language::translate($row['fieldlabel'], $moduleName);

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

            return ['labels' => $fieldlabel, 'table' => $fieldsList, 'fields' => $fieldsNames];

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

        public static function saveWidget($params)

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

            $tabid = $params['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

            return (new \App\Db\Query())->from('vtiger_widgets')->where(['tabid' => $tabid])->max('sequence');

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

         * Update sequence number.

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

        }

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

            while ($row = $dataReader->read()) {

    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

            return $checkBoxs;

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

         * @param array $params

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

         */

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

                $widgetInstance = new $widgetName($widgetModuleName);

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

                    $data['FastEdit'] = $FastEdit;

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

            if ($wid) {

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

                $db->createCommand()->update('vtiger_widgets', [

    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_widgets', ['sequence' => $value['index'], 'wcol' => $value['column']], ['tabid' => $tabid, 'id' => $key])

    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 getWYSIWYGFields($tabid, $module)

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

            return $field;

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

         * Function to get switch buttons for widget.

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

            $widgets = [1 => [], 2 => [], 3 => []];

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

            App\Cache::save('ModuleWidgets', $module, $widgets);

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

         * Return list of modules which have summary view.

    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

                    unset($modules[$id]);

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

            $loader[] = "modules/{$moduleModel->getName()}/widgets/";

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

            $loader[] = 'modules/Vtiger/widgets/';

    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 ($modules as $value) {

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

            $wid = $data['wid'] ?? '';

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

            $label = $data['label'] ?? '';

    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 $wid

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

            \App\Db::getInstance()->createCommand()->delete('vtiger_widgets', ['id' => $wid])->execute();

    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

            $data = $params['data'];

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

            foreach ($data as $key => $value) {

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

         * Return available fields with WYSIWYG.

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

         * @param string $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

            }

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

            $dataReader = $query->orderBy(['tabid' => SORT_ASC, 'sequence' => SORT_ASC])

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

        public function getSize()

    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 (!$fileInfo->isDir() && 'Basic' !== $type && 'php' === $fileInfo->getExtension() && !isset($folderFiles[$type])) {

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

            return $activeWidgets;

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

         *

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

                    while ($row = $dataReader->read()) {

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

                    $dataReader->close();

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

         *

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

            $dataReader = $query->createCommand()->query();

    Line exceeds 120 characters; contains 166 characters
    Open

                $fieldsList[$tabid][$row['tablename'] . '::' . $row['columnname'] . '::' . $row['fieldname']] = \App\Language::translate($row['fieldlabel'], $moduleName);

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

            if (isset($data['FastEdit'])) {

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

            \App\Cache::clear();

    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 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

                return \App\Cache::get('ModuleWidgets', $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

            $query = (new App\Db\Query())->from('vtiger_widgets');

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

                ->createCommand()->query();

    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 getType($module = false)

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

            $folderFiles = $activeWidgets = [];

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

                            $activeWidgets[$type] = $type;

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

        public function getFiletrs(array $modules): array

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

            $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

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

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

            unset($data['type']);

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

            $sequence = self::getLastSequence($tabid) + 1;

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

                    'data' => $serializeData,

    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 getWidgetInfo($wid)

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

        {

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

            $resultrow['data'] = \App\Json::decode($resultrow['data']);

    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

            $dataReader = (new \App\Db\Query())->select(['fieldlabel', 'fieldname'])

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

                $query->where(['tabid' => $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

                $loader[] = 'custom/modules/Vtiger/widgets/';

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

            foreach ($loader as $dir) {

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

                        $instance = new $className($moduleModel->getName(), $moduleModel);

    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

         * Function to get checkboxes.

    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

            } else {

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

            \App\Cache::delete('ModuleWidgets', $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

            $resultrow = (new \App\Db\Query())->from('vtiger_widgets')

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

         * @param array $params

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

            if (\App\Cache::has('ModuleWidgets', $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

         */

    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

                $fieldsList[$tabid][$row['tablename'] . '::' . $row['columnname'] . '::' . $row['fieldname']] = \App\Language::translate($row['fieldlabel'], $moduleName);

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

         *

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

            $type = $data['type'];

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

            $serializeData = \App\Json::encode($data);

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

                    'tabid' => $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

            return $resultrow;

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

         * Function to get last sequence number.

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

                $db->createCommand()

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

            $dataReader->close();

    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 ($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

         *

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

            return [1, 2, 3];

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

            if (\App\Config::performance('LOAD_CUSTOM_FILES')) {

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

                $loader[] = "custom/modules/{$moduleModel->getName()}/widgets/";

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

                        $className = Vtiger_Loader::getComponentClassName('Widget', $type, $moduleModel->getName());

    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 available columns of widgets.

    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 array $modules

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

                        ->createCommand()->query();

    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 list of fields for module and uitypes.

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

         * @param int        $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

                ])->execute();

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

        public static function updateSequence($params)

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

            while ($row = $dataReader->read()) {

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

                $moduleModel = Vtiger_Module_Model::getInstance($module['name']);

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

         * Return available sizes of widgets.

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

         * @return int[]

    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 to get types.

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

         *

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

            $moduleModel = Vtiger_Module_Model::getInstance($module);

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

                        $folderFiles[$type] = $type;

    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 array $modules

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

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])

    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 (!\in_array($value['related_tabid'], $tabid)) {

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

                ->where(['and', ['tabid' => $tabid], ['<>', 'displaytype', 2], ['presence' => [0, 2]]]);

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

            $moduleName = App\Module::getModuleName($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

            unset($data['label']);

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

                ->where(['id' => $wid])

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

                ->one();

    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 $modules;

    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 getColumns()

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

         * Function to get filters.

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

                if (!\in_array($value['related_tabid'], $tabid)) {

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

                        $filetrs[$value['related_tabid']][$row['fieldname']] = \App\Language::translate($row['fieldlabel'], $value['related_modulename']);

    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

        public function getCheckboxs(array $modules): array

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

            foreach ($modules as $value) {

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

                    $dataReader = (new \App\Db\Query())->select(['columnname', 'tablename', 'fieldlabel', 'fieldname'])

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

                        ->from('vtiger_field')

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

                    $dataReader->close();

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

            $query = (new \App\Db\Query())->select(['fieldid', 'columnname', 'tablename', 'fieldname', 'fieldlabel'])

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

            $dataReader->close();

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

                }

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

            unset($data['filter_selected'], $data['wid']);

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

                    'label' => $label,

    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 information about widget.

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

         * @param int $wid

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

            $field = [];

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

                ->where(['tabid' => $tabid, 'uitype' => 300])

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

            return $widgets;

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

         */

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

            $modules = \vtlib\Functions::getAllModules(true, true, 0);

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

         * @param int $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

         * @return array

    Line exceeds 120 characters; contains 150 characters
    Open

                        $filetrs[$value['related_tabid']][$row['fieldname']] = \App\Language::translate($row['fieldlabel'], $value['related_modulename']);

    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

                        ->andWhere(['<>', 'columnname', 'was_read'])

    Line exceeds 120 characters; contains 178 characters
    Open

                        $checkBoxs[$value['related_tabid']][$row['tablename'] . '.' . $row['fieldname']] = \App\Language::translate($row['fieldlabel'], $value['related_modulename']);

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

                    $tabid[] = $value['related_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

            if ($uitype) {

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

            $data = array_merge($dbParams, $data);

    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

            $tabid = $params['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

            foreach ($modules as $id => $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

         * @return array

    Line exceeds 120 characters; contains 133 characters
    Open

                    if (!$fileInfo->isDir() && 'Basic' !== $type && 'php' === $fileInfo->getExtension() && !isset($folderFiles[$type])) {

    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

                        ->where(['tabid' => $value['related_tabid'], 'uitype' => [15, 16]])

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

                        ->createCommand()->query();

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

                        $checkBoxs[$value['related_tabid']][$row['tablename'] . '.' . $row['fieldname']] = \App\Language::translate($row['fieldlabel'], $value['related_modulename']);

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

            while ($row = $dataReader->read()) {

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

            $data = $params['data'];

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

                if (!\is_array($data['FastEdit'])) {

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

                    'data' => $serializeData,

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

         * @param int $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

                $field[$row['fieldname']] = \App\Language::translate($row['fieldlabel'], $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

                ->createCommand()->query();

    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 getModulesList()

    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

         * Save widget.

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

            $widgetName = Vtiger_Loader::getComponentClassName('Widget', $data['type'], $widgetModuleName);

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

                ], ['id' => $wid])->execute();

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

                $db->createCommand()->insert('vtiger_widgets', [

    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 removeWidget($wid)

    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 type

    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 (!$moduleModel->isSummaryViewSupported()) {

    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 ((new \DirectoryIterator($dir)) as $fileInfo) {

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

                    $type = $fileInfo->getBasename('.php');

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

                        if ($instance->isPermitted()) {

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

            $filetrs = $tabid = [];

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

                    $tabid[] = $value['related_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

            $widgetModuleName = \App\Module::getModuleName($tabid);

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

                    'type' => $type,

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

         * @return int

    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

                ->from('vtiger_field')

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

         * @param array $index

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

                $row['data'] = \App\Json::decode($row['data']);

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

            $dataReader->close();

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

                if (!is_dir($dir)) {

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

                    continue;

    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[]|bool $uitype

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

                ->from('vtiger_field')

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

                $query->andWhere(['uitype' => $uitype]);

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

            if (class_exists($widgetName)) {

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

                $FastEdit = [];

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

                    'label' => $label,

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

                    'sequence' => $sequence,

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

         * Remove widget.

    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 getLastSequence($tabid)

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

                    ->update('vtiger_widgets', ['sequence' => $value['index'], 'wcol' => $value['column']], ['tabid' => $tabid, 'id' => $key])

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

            return [1, 2, 3, 4, 5, 6];

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

                        ->from('vtiger_field')

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

            return $filetrs;

    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' => $value['related_tabid'], 'uitype' => [56]])

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

            $fieldlabel = $fieldsList = $fieldsNames = [];

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

        {

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

                $dbParams = $widgetInstance->dbParams;

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

                    $FastEdit[] = $data['FastEdit'];

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

            \App\Cache::delete('ModuleWidgets', $tabid);

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

         * @param int    $tabid

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

         * @param mixed $sourceModule

    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($index)) {

    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

                            'label' => \App\Language::translate('LBL_HEADERSWITCH_OPEN_CLOSED', $moduleName),

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

        }

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

                    $customView[$module['related_tabid']][$cvId] = \App\Language::translate($cvModel->get('viewname'), $module['related_modulename']);

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

        {

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

            $data = [];

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

            if (isset($data[$index[0]][$index[1]])) {

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

            $customView = [];

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

                            'type' => 1,

    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 $data;

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

                return $data[$index[0]][$index[1]];

    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 $customView;

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

                $moduleName = $moduleData['related_modulename'];

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

                            'value' => [$fieldName => $statuses],

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

         * @param array $modules

    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

        public function getCustomView(array $modules): 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

         * Get custom views from related modules.

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

                foreach (CustomView_Record_Model::getAll($module['related_modulename']) as $cvId => $cvModel) {

    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 getHeaderSwitch($sourceModule, $index = [])

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

            return [];

    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 (($fieldName = \App\RecordStatus::getFieldName($moduleName)) && ($statuses = \App\RecordStatus::getStates($moduleName, \App\RecordStatus::RECORD_STATE_CLOSED))) {

    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

            $moduleName = is_numeric($sourceModule) ? \App\Module::getModuleName($sourceModule) : $sourceModule;

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

            foreach (\App\Relation::getByModule($moduleName) as $moduleData) {

    Line exceeds 120 characters; contains 177 characters
    Open

                if (($fieldName = \App\RecordStatus::getFieldName($moduleName)) && ($statuses = \App\RecordStatus::getStates($moduleName, \App\RecordStatus::RECORD_STATE_CLOSED))) {

    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 ($modules as $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

                    $data[$moduleData['related_tabid']] = [

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

                        [

    Line exceeds 120 characters; contains 146 characters
    Open

                    $customView[$module['related_tabid']][$cvId] = \App\Language::translate($cvModel->get('viewname'), $module['related_modulename']);

    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 "Settings_Widgets_Module_Model" is not in camel caps format
    Open

    class Settings_Widgets_Module_Model extends Settings_Vtiger_Module_Model

    The variable $FastEdit is not named in camelCase.
    Open

        public static function saveWidget($params)
        {
            $db = App\Db::getInstance();
            $tabid = $params['tabid'];
            $data = $params['data'];

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $FastEdit is not named in camelCase.
    Open

        public static function saveWidget($params)
        {
            $db = App\Db::getInstance();
            $tabid = $params['tabid'];
            $data = $params['data'];

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $FastEdit is not named in camelCase.
    Open

        public static function saveWidget($params)
        {
            $db = App\Db::getInstance();
            $tabid = $params['tabid'];
            $data = $params['data'];

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status