YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/LayoutEditor/actions/Field.php

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Function save has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    public function save(App\Request $request): void
    {
        $fieldId = $request->getInteger('fieldid');
        if (empty($fieldId)) {
            throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
Severity: Minor
Found in modules/Settings/LayoutEditor/actions/Field.php - About 1 day 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 save has 92 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function save(App\Request $request): void
    {
        $fieldId = $request->getInteger('fieldid');
        if (empty($fieldId)) {
            throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);
Severity: Major
Found in modules/Settings/LayoutEditor/actions/Field.php - About 3 hrs to fix

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

    class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action
    {
        /**
         * Constructor.
         */

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

        public function validate(App\Request $request): void
        {
            $data = [];
            $qualifiedModule = $request->getModule(false);
            foreach (['fieldType', 'fieldLabel', 'fieldName', 'pickListValues'] as $name) {
    Severity: Minor
    Found in modules/Settings/LayoutEditor/actions/Field.php - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    The method save() has an NPath complexity of 4160. The configured NPath complexity threshold is 200.
    Open

        public function save(App\Request $request): void
        {
            $fieldId = $request->getInteger('fieldid');
            if (empty($fieldId)) {
                throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

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

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

        public function save(App\Request $request): void
        {
            $fieldId = $request->getInteger('fieldid');
            if (empty($fieldId)) {
                throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);

    CyclomaticComplexity

    Since: 0.1

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

    Example

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

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

    Refactor this function to reduce its Cognitive Complexity from 60 to the 15 allowed.
    Open

        public function save(App\Request $request): void

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                                    $data['class'] = $request->getByType('header_class', \App\Purifier::STANDARD);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                                } elseif ('value' === $data['type'] && $fieldInstance->isReferenceField() && ($relFields = $request->getArray('header_rel_fields', \App\Purifier::ALNUM))) {

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                                $data['type'] = $request->getByType('header_type', \App\Purifier::STANDARD);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                                if ('highlights' === $data['type']) {

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

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

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                                            $data['rel_fields'][] = $fieldName;

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

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

    class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action
    {
        /**
         * Constructor.
         */

    CouplingBetweenObjects

    Since: 1.1.0

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

    Example

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

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

    Missing class import via use statement (line '316', column '19').
    Open

            $response = new Vtiger_Response();

    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 '289', column '19').
    Open

            $response = new Vtiger_Response();

    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 '204', column '19').
    Open

            $response = new Vtiger_Response();

    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 '118', column '19').
    Open

                                    throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . 'header_type', 406);

    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 '233', column '19').
    Open

            $response = new Vtiger_Response();

    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 '83', column '19').
    Open

            $response = new Vtiger_Response();

    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 '171', column '19').
    Open

            $response = new Vtiger_Response();

    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 '45', column '19').
    Open

            $response = new Vtiger_Response();

    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 '247', column '19').
    Open

            $response = new Vtiger_Response();

    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 '275', column '19').
    Open

            $response = new Vtiger_Response();

    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 '102', column '14').
    Open

                throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);

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

                    'label' => \App\Language::translate($fieldInstance->get('label'), $request->getByType('sourceModule', 2)), ]);

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'Settings_LayoutEditor_Field_Model' in method 'delete'.
    Open

            $fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($request->getInteger('fieldid'));

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

            } else {
                try {
                    $fieldInstance->delete();
                    $response->setResult(['success' => true]);
                } catch (Exception $e) {

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class 'Vtiger_Field_Model' in method 'getPicklist'.
    Open

                $fieldInstance = Vtiger_Field_Model::getInstance($fieldName, $moduleModel);

    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 '123', column '86').
    Open

        public function save(App\Request $request): void
        {
            $fieldId = $request->getInteger('fieldid');
            if (empty($fieldId)) {
                throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);

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

                                $value = \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\Json' in method 'save'.
    Open

                $fieldInstance->set('fieldparams', $params ? \App\Json::encode($params) : '');

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

                $response->setResult(['success' => false, 'message' => \App\Language::translate('LBL_NON_CUSTOM_FIELD_CANNOT_DELETE', 'Settings::LayoutEditor')]);

    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\Fields\Picklist' in method 'checkPicklistExist'.
    Open

            $response->setResult(\App\Fields\Picklist::isPicklistExist($request->getByType('fieldName', 'Alnum')));

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                            } else {
                                $value = '';
                            }

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class 'Settings_LayoutEditor_Block_Model' in method 'move'.
    Open

            Settings_LayoutEditor_Block_Model::updateFieldSequenceNumber($request->getMultiDimensionArray('updatedFields',
            [
                'block' => 'Integer',
                'fieldid' => 'Integer',
                'sequence' => 'Integer',

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

                    } else {
                        $value = $request->getByType($name, \App\Purifier::TEXT);
                    }

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

        public function save(App\Request $request): void
        {
            $fieldId = $request->getInteger('fieldid');
            if (empty($fieldId)) {
                throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);

    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 'Vtiger_Module_Model' in method 'getPicklist'.
    Open

                $moduleModel = Vtiger_Module_Model::getInstance($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_Module_Model' in method 'save'.
    Open

                                    $relModuleModel = \Vtiger_Module_Model::getInstance(current($fieldInstance->getReferenceList()));

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'Settings_LayoutEditor_Field_Model' in method 'unHide'.
    Open

                    Settings_LayoutEditor_Field_Model::makeFieldActive($fieldIds, $request->getInteger('blockId'));

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'Settings_LayoutEditor_Field_Model' in method 'save'.
    Open

            $fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($fieldId);

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'Settings_LayoutEditor_Field_Model' in method 'unHide'.
    Open

                        $fieldModel = Settings_LayoutEditor_Field_Model::getInstance($fieldId);

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'Settings_Vtiger_Tracker_Model' in method '__construct'.
    Open

            Settings_Vtiger_Tracker_Model::addBasic('save');

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                    } else {
                        $fieldInstance->set('defaultvalue', '');
                    }

    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

    Define a constant instead of duplicating this literal "success" 4 times.
    Open

                    'success' => true,

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

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

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

                if ($request->has('defaultvalue')) {

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

                'block' => 'Integer',

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

            $fieldId = $request->getInteger('fieldid');

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

            $type = $request->getByType('fieldType', 'Alnum');

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

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

            $blockId = $request->getInteger('blockid');

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

                                if (!\in_array($request->getByType('header_type', \App\Purifier::STANDARD), $uitypeModel->getHeaderTypes())) {

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

            $moduleName = $request->getByType('sourceModule', 'Alnum');

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

            if ($request->has('anonymizationTarget')) {

    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.

    Argument 1 (value) is int but \Settings_LayoutEditor_Field_Model::getInstance() takes string defined at /code/modules/Settings/LayoutEditor/models/Field.php:359
    Open

            $fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($request->getInteger('fieldid'));

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

                                $data['type'] = $request->getByType('header_type', \App\Purifier::STANDARD);

    Argument 1 (value) is int but \Settings_LayoutEditor_Field_Model::getInstance() takes string defined at /code/modules/Settings/LayoutEditor/models/Field.php:359
    Open

            $fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($fieldId);

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

    class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action

    The class Settings_LayoutEditor_Field_Action is not named in CamelCase.
    Open

    class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action
    {
        /**
         * Constructor.
         */

    CamelCaseClassName

    Since: 0.2

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

    Example

    class class_name {
    }

    Source

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

            parent::__construct();

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

         * @param \App\Request $request

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

            $this->exposeMethod('checkPicklistExist');

    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 add(App\Request $request): void

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

         * Constructor.

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

            $this->exposeMethod('delete');

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

        /**

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

            $this->exposeMethod('move');

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

        public function __construct()

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

            $this->exposeMethod('getPicklist');

    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

            $this->exposeMethod('validate');

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

            $this->exposeMethod('add');

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

            $this->exposeMethod('save');

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

            $this->exposeMethod('unHide');

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

         * @return void

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

         * Create field.

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

        {

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

         *

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

         */

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

            $this->exposeMethod('createSystemField');

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

            Settings_Vtiger_Tracker_Model::addBasic('save');

    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

                throw new \App\Exceptions\AppException('Empty field ID: ' . $fieldId);

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

                                } elseif ('value' === $data['type'] && $fieldInstance->isReferenceField() && ($relFields = $request->getArray('header_rel_fields', \App\Purifier::ALNUM))) {

    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

                        case 'quickcreate':

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

                            $fieldVal = null;

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

                    if ($request->getBoolean('defaultvalue')) {

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

            } catch (Exception $e) {

    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[$name] = $value;

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

                }

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

                $params['mask'] = $request->getByType('fieldMask', 'Text');

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

                    'presence' => $request->getBoolean('presence') ? '1' : '0',

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

            $type = $request->getByType('fieldType', 'Alnum');

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

            $moduleModel = Settings_LayoutEditor_Module_Model::getInstance($request->getModule(false))->setSourceModule($moduleName);

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

                if ($request->has($name)) {

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

        /**

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

                    switch ($field) {

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

                                    throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . 'header_type', 406);

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

                                $data['type'] = $request->getByType('header_type', \App\Purifier::STANDARD);

    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 \App\Request $request

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

                    if ('pickListValues' === $name) {

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

    Line exceeds 120 characters; contains 138 characters
    Open

                                if (!\in_array($request->getByType('header_type', \App\Purifier::STANDARD), $uitypeModel->getHeaderTypes())) {

    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 ('highlights' === $data['type']) {

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

                                    $relModuleModel = \Vtiger_Module_Model::getInstance(current($fieldInstance->getReferenceList()));

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

                            if ($fieldInstance->get('quickcreate') !== $quickCreateValue && $quickCreateValue > 0) {

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

                                $iconField = $fieldInstance->getFieldItemByName($field);

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

                    unset($params['mask']);

    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

                    'label' => \App\Language::translate($fieldInstance->get('label'), $request->getByType('sourceModule', 2)), ]);

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

                $fieldInfo = $fieldModel->getFieldInfo();

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

                    'id' => $fieldModel->getId(),

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

            $response->emit();

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

            foreach (['fieldType', 'fieldLabel', 'fieldName', 'pickListValues'] as $name) {

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

                        $value = $request->getArray($name, \App\Purifier::TEXT);

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

         * @throws \App\Exceptions\AppException

    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($request->getByType('header_type', \App\Purifier::STANDARD), $uitypeModel->getHeaderTypes())) {

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

                                    foreach ($relFields as $fieldName) {

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

                                            $data['rel_fields'][] = $fieldName;

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

                            $fieldInstance->set($field, $request->getInteger($field));

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

            $response = new Vtiger_Response();

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

                $response->setResult($responseData);

    Line exceeds 120 characters; contains 129 characters
    Open

            $moduleModel = Settings_LayoutEditor_Module_Model::getInstance($request->getModule(false))->setSourceModule($moduleName);

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

        public function validate(App\Request $request): void

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

            $uitypeModel = $fieldInstance->getUITypeModel();

    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 ($request->getBoolean($field)) {

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

            $fieldId = $request->getInteger('fieldid');

    Line exceeds 120 characters; contains 184 characters
    Open

                                } elseif ('value' === $data['type'] && $fieldInstance->isReferenceField() && ($relFields = $request->getArray('header_rel_fields', \App\Purifier::ALNUM))) {

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

                            break;

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

                            break;

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

                                    $data['class'] = $request->getByType('header_class', \App\Purifier::STANDARD);

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

                            $quickCreateValue = $request->getInteger($field);

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

            }

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

                            }

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

                $responseData = array_merge([

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

            if ($request->has('fieldMask')) {

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

                                $fieldInstance->set('quicksequence', $fieldInstance->__getNextQuickCreateSequence());

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

        /**

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

                $params = $fieldInstance->getFieldParams();

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

                            }

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

                $fieldInstance->set('anonymizationTarget', $request->getArray('anonymizationTarget', \App\Purifier::INTEGER));

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

                            $fieldInstance->set($field, $quickCreateValue);

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

            $moduleModel = Settings_LayoutEditor_Module_Model::getInstance($qualifiedModule)->setSourceModule($request->getByType('sourceModule', \App\Purifier::ALNUM));

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

            }

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

                $response->setResult([

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

            $fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($fieldId);

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

                                        }

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

                            $fieldInstance->set($field, $value);

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

                                $fieldUITypeModel = $iconField->getUITypeModel();

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

            }

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

                    'mandatory' => $fieldInstance->isMandatory(),

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

            $qualifiedModule = $request->getModule(false);

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

            $response->setResult($moduleModel->validate($data, false));

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

                            break;

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

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

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

                        case 'icon':

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

                if (empty($params['mask'])) {

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

            try {

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

                $fieldModel = $moduleModel->addField($type, $blockId, $request->getAll());

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

                $response->setError($e->getCode(), $e->getMessage());

    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

         * @param \App\Request $request

    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 (!$request->isEmpty($field) && ($value = $request->getByType($field, \App\Purifier::TEXT))) {

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

                            break;

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

                        $fieldInstance->set('defaultvalue', '');

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

            $blockId = $request->getInteger('blockid');

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

                    'customField' => $fieldModel->isCustomField(), ], $fieldInfo);

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

            foreach (Settings_LayoutEditor_Module_Model::EDIT_FIELDS_FORM as $field) {

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

                            $fieldInstance->updateTypeofDataFromMandatory($request->getByType($field, \App\Purifier::STANDARD));

    Line exceeds 120 characters; contains 124 characters
    Open

                            $fieldInstance->updateTypeofDataFromMandatory($request->getByType($field, \App\Purifier::STANDARD));

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

                            break;

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

                        default:

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

         *

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

            $response->emit();

    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 void

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

                if ($request->has($field)) {

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

                        case 'mandatory':

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

                        case 'label':

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

                            $fieldInstance->set($field, $request->getByType($field, \App\Purifier::TEXT));

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

                    'blockid' => $blockId,

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

         * Validate field.

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

         *

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

         * @return void

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

                        $value = $request->getByType($name, \App\Purifier::TEXT);

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

            $response = new Vtiger_Response();

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

        {

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

                        case 'header_field':

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

                                    }

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

                                $value = '';

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

                            }

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

                }

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

                $fieldInstance->set('fieldparams', $params ? \App\Json::encode($params) : '');

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

            }

    Line exceeds 120 characters; contains 122 characters
    Open

                $fieldInstance->set('anonymizationTarget', $request->getArray('anonymizationTarget', \App\Purifier::INTEGER));

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

            $moduleName = $request->getByType('sourceModule', 'Alnum');

    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

                    }

    Line exceeds 120 characters; contains 165 characters
    Open

            $moduleModel = Settings_LayoutEditor_Module_Model::getInstance($qualifiedModule)->setSourceModule($request->getByType('sourceModule', \App\Purifier::ALNUM));

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

         *

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

                            $fieldInstance->set('icon', $fieldVal);

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

                    }

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

                    'success' => true,

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

                    'name' => $fieldModel->get('name'),

    Line exceeds 120 characters; contains 129 characters
    Open

                                    $relModuleModel = \Vtiger_Module_Model::getInstance(current($fieldInstance->getReferenceList()));

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

                                        if ($relModuleModel->getFieldByName($fieldName)->isViewableInDetailView()) {

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

                                }

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

                                $fieldVal = $iconField->getDBValue($value);

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

                            break;

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

            $response = new Vtiger_Response();

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

                if ($request->has('defaultvalue')) {

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

                        $uitypeModel->setDefaultValueFromRequest($request);

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

                $fieldInstance->save();

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

                }

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

         * @throws \App\Exceptions\IllegalValue

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

        public function save(App\Request $request): void

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

            if (empty($fieldId)) {

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

                                $fieldUITypeModel->validate($value, true);

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

            if ($request->has('anonymizationTarget')) {

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

            try {

    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

                    $response->setResult($responseData);

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

            $picklistValues = [];

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

        {

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

            } catch (Exception $e) {

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

                $response->setResult(['success' => false, 'message' => \App\Language::translate('LBL_NON_CUSTOM_FIELD_CANNOT_DELETE', 'Settings::LayoutEditor')]);

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

                        $fieldModel = Settings_LayoutEditor_Field_Model::getInstance($fieldId);

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

            } catch (Exception $e) {

    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

                try {

    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

            try {

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

         * @return void

    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 void

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

         * @return void

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

            } catch (Exception $e) {

    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

                $fieldInstance = Vtiger_Field_Model::getInstance($fieldName, $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

            $moduleModel = Settings_LayoutEditor_Module_Model::getInstance($request->getModule(false))->setSourceModule($moduleName);

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

         * @param \App\Request $request

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

                }

    Line exceeds 120 characters; contains 129 characters
    Open

            $moduleModel = Settings_LayoutEditor_Module_Model::getInstance($request->getModule(false))->setSourceModule($moduleName);

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

         * Check if picklist exist.

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

                $response->setResult(true);

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

        }

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

         * Create system field.

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

            try {

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

            }

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

            $response->emit();

    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 void

    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 void

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

            Settings_LayoutEditor_Block_Model::updateFieldSequenceNumber($request->getMultiDimensionArray('updatedFields',

    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 void

    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 getPicklist(App\Request $request): void

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

            if (!empty($fieldName) && !empty($moduleName) && '-' != $fieldName) {

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

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

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

                    $picklistValues = [];

    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

            $response = new Vtiger_Response();

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

         * @param \App\Request $request

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

                    $fieldInstance->delete();

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

        public function unHide(App\Request $request): void

    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 checkPicklistExist(App\Request $request): void

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

            $response = new Vtiger_Response();

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

            $response->emit();

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

            $fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($request->getInteger('fieldid'));

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

                        $responseData[] = array_merge(['id' => $fieldModel->getId(), 'blockid' => $fieldModel->get('block')->id, 'customField' => $fieldModel->isCustomField()], $fieldInfo);

    Line exceeds 120 characters; contains 185 characters
    Open

                        $responseData[] = array_merge(['id' => $fieldModel->getId(), 'blockid' => $fieldModel->get('block')->id, 'customField' => $fieldModel->isCustomField()], $fieldInfo);

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

            $response->emit();

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

         * @param \App\Request $request

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

            $response->setResult($picklistValues);

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

                ]);

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

         * Delete field.

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

         *

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

        public function delete(App\Request $request): void

    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

            $response = new Vtiger_Response();

    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

            $response = new Vtiger_Response();

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

            $response->emit();

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

            $fieldName = $request->getByType('rfield', 'Alnum');

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

                $picklistValues = $fieldInstance->getPicklistValues();

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

                $response->setError($e->getCode(), $e->getMessage());

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

            }

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

            $response = new Vtiger_Response();

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

            if (!$fieldInstance->isCustomField()) {

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

        /**

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

         * Make field active.

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

                    $responseData = [];

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

                        $fieldInfo = $fieldModel->getFieldInfo();

    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 = $request->getByType('sourceModule', 'Alnum');

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

                $moduleModel->addSystemField($request->getByType('field', 'Alnum'), $request->getInteger('blockId'), [

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

                    'generatedtype' => 2,

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

            } catch (Error $e) {

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

                } catch (Exception $e) {

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

         * Move field.

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

            $response->emit();

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

                    Settings_LayoutEditor_Field_Model::makeFieldActive($fieldIds, $request->getInteger('blockId'));

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

                    foreach ($fieldIds as $fieldId) {

    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

            $response->setResult(\App\Fields\Picklist::isPicklistExist($request->getByType('fieldName', 'Alnum')));

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

         */

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

            $response = new Vtiger_Response();

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

                $response->setError($e->getCode(), $e->getMessage());

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

                'fieldid' => 'Integer',

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

                if (!empty($fieldIds)) {

    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

                $response->setError($e->getCode(), $e->getMessage());

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

        public function move(App\Request $request): void

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

            ]));

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

            $response->setResult(['success' => true]);

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

                $fieldIds = $request->getArray('fieldIdList', 'Integer');

    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 picklist values.

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

         *

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

                    $response->setResult(['success' => true]);

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

                'block' => 'Integer',

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

                if (null === $picklistValues) {

    Line exceeds 120 characters; contains 126 characters
    Open

                    'label' => \App\Language::translate($fieldInstance->get('label'), $request->getByType('sourceModule', 2)), ]);

    Line exceeds 120 characters; contains 158 characters
    Open

                $response->setResult(['success' => false, 'message' => \App\Language::translate('LBL_NON_CUSTOM_FIELD_CANNOT_DELETE', 'Settings::LayoutEditor')]);

    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

                    $response->setError($e->getCode(), $e->getMessage());

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

            $response->emit();

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

         * @param \App\Request $request

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

                'sequence' => 'Integer',

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

                $response->setError($e->getCode(), $e->getMessage());

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

         * @param \App\Request $request

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

            $response->emit();

    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 \App\Request $request

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

            $moduleName = $request->getByType('rmodule', 'Alnum');

    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 createSystemField(App\Request $request): void

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

    class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action

    Opening parenthesis of a multi-line function call must be the last content on the line
    Open

            Settings_LayoutEditor_Block_Model::updateFieldSequenceNumber($request->getMultiDimensionArray('updatedFields',

    Multi-line function call not indented correctly; expected 12 spaces but found 8
    Open

            [

    Closing parenthesis of a multi-line function call must be on a line by itself
    Open

            ]));

    There are no issues that match your filters.

    Category
    Status