YetiForceCompany/YetiForceCRM

View on GitHub
modules/ModComments/models/Record.php

Summary

Maintainability
C
1 day
Test Coverage
F
5%

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

class ModComments_Record_Model extends Vtiger_Record_Model
{
    /** @var \Vtiger_Record_Model Commentator record model instance. */
    private $commentatorModel;

Severity: Minor
Found in modules/ModComments/models/Record.php by phpmd

Function getSearchComments has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
    {
        $fields = array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']);
        $queryGenerator = new \App\QueryGenerator('ModComments');
        $queryGenerator->setFields($fields);
Severity: Minor
Found in modules/ModComments/models/Record.php - About 3 hrs 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

File Record.php has 282 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/* +***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
Severity: Minor
Found in modules/ModComments/models/Record.php - About 2 hrs to fix

    Method getSearchComments has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
        {
            $fields = array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']);
            $queryGenerator = new \App\QueryGenerator('ModComments');
            $queryGenerator->setFields($fields);
    Severity: Major
    Found in modules/ModComments/models/Record.php - About 2 hrs to fix

      Method getAllParentComments has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getAllParentComments(int $parentId, string $moduleName, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
          {
              $queryGenerator = new \App\QueryGenerator('ModComments');
              $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
              $queryGenerator->setSourceRecord($parentId);
      Severity: Minor
      Found in modules/ModComments/models/Record.php - About 1 hr to fix

        Method getCommentLinks has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getCommentLinks()
            {
                $links = [];
                $stateColors = App\Config::search('LIST_ENTITY_STATE_COLOR');
                if ($this->privilegeToArchive()) {
        Severity: Minor
        Found in modules/ModComments/models/Record.php - About 1 hr to fix

          Function getAllParentComments has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function getAllParentComments(int $parentId, string $moduleName, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
              {
                  $queryGenerator = new \App\QueryGenerator('ModComments');
                  $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
                  $queryGenerator->setSourceRecord($parentId);
          Severity: Minor
          Found in modules/ModComments/models/Record.php - About 55 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

          Method getSearchComments has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
          Severity: Minor
          Found in modules/ModComments/models/Record.php - About 45 mins to fix

            The method getSearchComments() has an NPath complexity of 1377. The configured NPath complexity threshold is 200.
            Open

                public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
                {
                    $fields = array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']);
                    $queryGenerator = new \App\QueryGenerator('ModComments');
                    $queryGenerator->setFields($fields);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            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 getAllParentComments() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
            Open

                public static function getAllParentComments(int $parentId, string $moduleName, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
                {
                    $queryGenerator = new \App\QueryGenerator('ModComments');
                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
                    $queryGenerator->setSourceRecord($parentId);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            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 method getSearchComments() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
            Open

                public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
                {
                    $fields = array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']);
                    $queryGenerator = new \App\QueryGenerator('ModComments');
                    $queryGenerator->setFields($fields);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            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 29 to the 15 allowed.
            Open

                public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

            See

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

            class ModComments_Record_Model extends Vtiger_Record_Model
            {
                /** @var \Vtiger_Record_Model Commentator record model instance. */
                private $commentatorModel;
            
            
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            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 '253', column '25').
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '327', column '25').
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '234', column '25').
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '193', column '25').
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '200', column '24').
            Open

                            $query->union((new \App\Db\Query())->select([new \yii\db\Expression($parentId)]));
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '339', column '37').
            Open

                        $where[] = ['related_to' => (new \App\Db\Query())->select(['id'])->from(['temp_query' => $query])];
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '299', column '25').
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '200', column '54').
            Open

                            $query->union((new \App\Db\Query())->select([new \yii\db\Expression($parentId)]));
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '367', column '34').
            Open

                            $queryGeneratorParents = new \App\QueryGenerator('ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '202', column '35').
            Open

                        $where = ['related_to' => (new \App\Db\Query())->select(['id'])->from(['temp_query' => $query])];
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

            Missing class import via use statement (line '272', column '25').
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            MissingImport

            Since: 2.7.0

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

            Example

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

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

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

                public static function getAllParentComments(int $parentId, string $moduleName, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
                {
                    $queryGenerator = new \App\QueryGenerator('ModComments');
                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
                    $queryGenerator->setSourceRecord($parentId);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

            Avoid using static access to class '\App\ModuleHierarchy' in method 'getSearchComments'.
            Open

                    if (\count($hierarchy) > $requireCount && ($query = \App\ModuleHierarchy::getQueryRelatedRecords($parentId, $hierarchy))) {
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                            'linkdata' => ['confirm' => \App\Language::translate('LBL_MOVE_TO_TRASH_DESC'), 'source-view' => 'DetailTab'],
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                public function getCommentedByModel(): ?Vtiger_Record_Model
                {
                    if (isset($this->commentatorModel)) {
                        return $this->commentatorModel;
                    }
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

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

                            } else {
                                $commentsId[] = $row['id'];
                            }
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            ElseExpression

            Since: 1.4.0

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

            Example

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

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

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

                            'linkdata' => ['confirm' => \App\Language::translate('LBL_ARCHIVE_RECORD_DESC'), 'source-view' => 'DetailTab'],
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                public function getParentCommentModel(): ?Vtiger_Record_Model
                {
                    if (isset($this->parentCommentModel)) {
                        return $this->parentCommentModel;
                    }
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

            Avoid using static access to class '\App\Field' in method 'getSearchComments'.
            Open

                    $fields = array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class '\App\ModuleHierarchy' in method 'getSearchComments'.
            Open

                    $moduleLevel = \App\ModuleHierarchy::getModuleLevel($moduleName);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                public function getCommentedByModel(): ?Vtiger_Record_Model
                {
                    if (isset($this->commentatorModel)) {
                        return $this->commentatorModel;
                    }
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

            Avoid using static access to class 'Vtiger_Record_Model' in method 'getParentRecordModel'.
            Open

                        $parentModel = Vtiger_Record_Model::getInstanceById($parentRecordId);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                    } else {
                        $where = ['related_to' => 0];
                    }
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            ElseExpression

            Since: 1.4.0

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

            Example

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

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

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

                            'title' => \App\Language::translate('LBL_MOVE_TO_TRASH'),
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class 'Vtiger_Record_Model' in method 'getParentCommentModel'.
            Open

                        $parentCommentModel = Vtiger_Record_Model::getInstanceById($recordId, 'ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                public function getParentRecordModel(): ?Vtiger_Record_Model
                {
                    if (isset($this->parentModel)) {
                        return $this->parentModel;
                    }
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

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

                public function getImage()
                {
                    if (1 == $this->get('from_mailconverter')) {
                        return \App\Layout::getImagePath('MailConverterComment.png');
                    }
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

            Avoid using static access to class '\App\ModuleHierarchy' in method 'getAllParentComments'.
            Open

                    $moduleLevel = \App\ModuleHierarchy::getModuleLevel($moduleName);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                    } else {
                        $commentsId = [];
                        while ($row = $dataReader->read()) {
                            $parentTempId = strstr($row['parents'], '::', true) ?: $row['parents'];
                            if (!empty($parentTempId) && !$isWidget) {
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            ElseExpression

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class 'Vtiger_Record_Model' in method 'getCommentedByModel'.
            Open

                        $this->commentatorModel = Vtiger_Record_Model::getInstanceById($commentedBy, 'Users');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class '\App\Field' in method 'getChildComments'.
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)
                {
                    $fields = array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']);
                    $queryGenerator = new \App\QueryGenerator('ModComments');
                    $queryGenerator->setFields($fields);
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

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

                public function getCommentatorName(): string
                {
                    $label = '';
                    if ($this->get('assigned_user_id')) {
                        $label = $this->getDisplayValue('assigned_user_id');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

            Avoid using static access to class 'App\Config' in method 'getCommentLinks'.
            Open

                    $stateColors = App\Config::search('LIST_ENTITY_STATE_COLOR');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                            'title' => \App\Language::translate('LBL_ARCHIVE_RECORD'),
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                public function getImage()
                {
                    if (1 == $this->get('from_mailconverter')) {
                        return \App\Layout::getImagePath('MailConverterComment.png');
                    }
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

            Avoid using static access to class '\App\Fields\ServerAccess' in method 'getCommentLinks'.
            Open

                    if ($link = \App\Fields\ServerAccess::getLinks($this, 'ModComments')) {
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class 'Vtiger_Record_Model' in method 'getCommentedByModel'.
            Open

                        $this->commentatorModel = Vtiger_Record_Model::getInstanceById($customer, 'Contacts');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class '\App\User' in method 'getCommentedByModel'.
            Open

                    } elseif (($commentedBy = $this->get('assigned_user_id')) && \App\User::isExists($commentedBy, false)) {
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class '\App\ModuleHierarchy' in method 'getAllParentComments'.
            Open

                    if (\count($hierarchy) > $requireCount && ($query = \App\ModuleHierarchy::getQueryRelatedRecords($parentId, $hierarchy))) {
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class 'Vtiger_Link_Model' in method 'getCommentLinks'.
            Open

                        $links[] = Vtiger_Link_Model::getInstanceFromValues([
                            'linklabel' => 'LBL_MOVE_TO_TRASH',
                            'title' => \App\Language::translate('LBL_MOVE_TO_TRASH'),
                            'dataUrl' => 'index.php?module=' . $this->getModuleName() . '&action=State&state=Trash&sourceView=List&record=' . $this->getId(),
                            'linkdata' => ['confirm' => \App\Language::translate('LBL_MOVE_TO_TRASH_DESC'), 'source-view' => 'DetailTab'],
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class 'App\User' in method 'getValuesForSave'.
            Open

                        $forSave['vtiger_modcomments']['userid'] = App\User::getCurrentUserRealId();
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class '\App\Field' in method 'getAllParentComments'.
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class '\App\Field' in method 'getParentComments'.
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class 'Vtiger_Link_Model' in method 'getCommentLinks'.
            Open

                        $links[] = Vtiger_Link_Model::getInstanceFromValues([
                            'linklabel' => 'LBL_ARCHIVE_RECORD',
                            'title' => \App\Language::translate('LBL_ARCHIVE_RECORD'),
                            'dataUrl' => 'index.php?module=' . $this->getModuleName() . '&action=State&state=Archived&sourceView=List&record=' . $this->getId(),
                            'linkdata' => ['confirm' => \App\Language::translate('LBL_ARCHIVE_RECORD_DESC'), 'source-view' => 'DetailTab'],
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class '\App\User' in method 'isEditable'.
            Open

                        return $this->privileges['isEditable'] = \App\User::getCurrentUserRealId() === (int) $this->get('userid') && parent::isEditable() && $this->isPermitted('EditableComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

            Avoid using static access to class '\App\Layout' in method 'getImage'.
            Open

                        return \App\Layout::getImagePath('MailConverterComment.png');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                public function getCommentLinks()
                {
                    $links = [];
                    $stateColors = App\Config::search('LIST_ENTITY_STATE_COLOR');
                    if ($this->privilegeToArchive()) {
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            IfStatementAssignment

            Since: 2.7.0

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

            Example

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

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

            Define a constant instead of duplicating this literal "related_to" 13 times.
            Open

                    if ($parentRecordId = $this->get('related_to')) {
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

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

                    if ($customer = $this->get('customer')) {
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

            Rename "$parentCommentModel" which has the same name as the field declared at line 24.
            Open

                    $parentCommentModel = null;

            Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

            Noncompliant Code Example

            class Foo {
              public $myField;
            
              public function doSomething() {
                $myField = 0;
                ...
              }
            }
            

            See

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

                    if (!isset($this->privileges['isEditable'])) {
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

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

                    if ($pagingModel && 0 !== $pagingModel->get('limit')) {
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

            Define a constant instead of duplicating this literal "ModComments" 13 times.
            Open

                        $parentCommentModel = Vtiger_Record_Model::getInstanceById($recordId, 'ModComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

            Define a constant instead of duplicating this literal "modcommentsid" 6 times.
            Open

                    $id = $this->get('modcommentsid');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

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

                    $parentCommentId = explode('::', $this->get('parents'))[0];
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

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

                    } elseif (($commentedBy = $this->get('assigned_user_id')) && \App\User::isExists($commentedBy, false)) {
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

            Rename "$parentModel" which has the same name as the field declared at line 21.
            Open

                    $parentModel = null;

            Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

            Noncompliant Code Example

            class Foo {
              public $myField;
            
              public function doSomething() {
                $myField = 0;
                ...
              }
            }
            

            See

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

                        return $this->privileges['isEditable'] = \App\User::getCurrentUserRealId() === (int) $this->get('userid') && parent::isEditable() && $this->isPermitted('EditableComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

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

                    if ($recordId = $this->get('parent_comments')) {
            Severity: Critical
            Found in modules/ModComments/models/Record.php by sonar-php

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

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

            Noncompliant Code Example

            With the default threshold of 3:

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

            Compliant Solution

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

            Exceptions

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

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->addNativeCondition(['parent_comments' => 0]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->addNativeCondition(['parent_comments' => $recordId, 'related_to' => $this->get('related_to')]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $dataReader = $queryGenerator->createQuery()->createCommand()->query();
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Expected @param annotation for moduleName to be before the @param annotation for searchValue
            Open

                 * @param string              $searchValue

            Call to method getModuleModel from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                                $recordInstance->setData($row)->setModuleFromInstance($queryGeneratorParents->getModuleModel());
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method isExists from undeclared class \App\User (Did you mean class \Tests\App\User)
            Open

                    } elseif (($commentedBy = $this->get('assigned_user_id')) && \App\User::isExists($commentedBy, false)) {
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

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

                        $where = ['related_to' => (new \App\Db\Query())->select(['id'])->from(['temp_query' => $query])];
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setFields([]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Return type of getChildComments() is undeclared type \ModComment_Record_Model[]
            Open

                public function getChildComments()
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phan

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->addNativeCondition($where);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method getCurrentUserRealId from undeclared class \App\User (Did you mean class \Tests\App\User)
            Open

                        $forSave['vtiger_modcomments']['userid'] = App\User::getCurrentUserRealId();
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setSourceRecord from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setSourceRecord($parentId);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setSourceRecord from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setSourceRecord($parentId);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $query = $queryGenerator->createQuery()->orderBy(['vtiger_crmentity.createdtime' => SORT_DESC]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setFields([]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Doc-block of $pagingModel in getAllParentComments is phpdoc param type \Vtiger_Paging_Model which is not a permitted replacement of the nullable param type ?\Vtiger_Paging_Model declared in the signature ('?T' should be documented as 'T|null' or '?T')
            Open

                 * @param Vtiger_Paging_Model $pagingModel
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phan

            Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setSourceRecord from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setSourceRecord($recordId);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setFields($fields);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Expected @param annotation for moduleName to be before the @param annotation for hierarchy
            Open

                 * @param int[]               $hierarchy

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

                            $query->union((new \App\Db\Query())->select([new \yii\db\Expression($parentId)]));
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method getModuleModel from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                        $recordInstance->setData($row)->setModuleFromInstance($queryGenerator->getModuleModel());
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $dataReader = $queryGenerator->createQuery()->createCommand()->query();
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    return $queryGenerator->createQuery()->count();
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Returning type void but getParentComments() is declared to return \ModComment_Record_Model[]
            Open

                        return;
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phan

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->addNativeCondition(['like', 'commentcontent', '%' . $searchValue . '%', false]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                            $queryGeneratorParents->setFields($fields);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

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

                            $query->union((new \App\Db\Query())->select([new \yii\db\Expression($parentId)]));
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setSourceRecord from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setSourceRecord($recordId);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->addNativeCondition(['related_to' => $recordId]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->addNativeCondition(['parent_comments' => $parentCommentId, 'related_to' => $this->get('related_to')]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                            $parentQuery = $queryGeneratorParents->createQuery();
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    return $queryGenerator->createQuery()->count('modcommentsid');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method getModuleModel from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                        $recordInstance->setData($row)->setModuleFromInstance($queryGenerator->getModuleModel());
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Doc-block of $pagingModel in getSearchComments is phpdoc param type \Vtiger_Paging_Model which is not a permitted replacement of the nullable param type ?\Vtiger_Paging_Model declared in the signature ('?T' should be documented as 'T|null' or '?T')
            Open

                 * @param Vtiger_Paging_Model $pagingModel
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phan

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->addNativeCondition(['modcommentsid' => $parentCommentId, 'related_to' => $this->get('related_to')]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $query = $queryGenerator->createQuery()->orderBy(['vtiger_crmentity.createdtime' => SORT_DESC]);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method getModuleModel from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                            $recordInstance->setData($row)->setModuleFromInstance($queryGenerator->getModuleModel());
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->addNativeCondition($where);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

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

                        $where[] = ['related_to' => (new \App\Db\Query())->select(['id'])->from(['temp_query' => $query])];
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

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

                            $query->union((new \App\Db\Query())->select([new \yii\db\Expression($parentId)]));
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method getModuleModel from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                        $recordInstance->setData($row)->setModuleFromInstance($queryGenerator->getModuleModel());
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator = new \App\QueryGenerator('ModComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method getCurrentUserRealId from undeclared class \App\User (Did you mean class \Tests\App\User)
            Open

                        return $this->privileges['isEditable'] = \App\User::getCurrentUserRealId() === (int) $this->get('userid') && parent::isEditable() && $this->isPermitted('EditableComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Returning type void but getChildComments() is declared to return \ModComment_Record_Model[]
            Open

                        return;
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phan

            Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                            $queryGeneratorParents->addNativeCondition(['in', 'modcommentsid', array_unique($commentsId)], false);
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Return type of getParentComments() is undeclared type \ModComment_Record_Model[]
            Open

                public function getParentComments()
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phan

            Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
            Open

                            $queryGeneratorParents = new \App\QueryGenerator('ModComments');
            Severity: Critical
            Found in modules/ModComments/models/Record.php by phan

            Avoid excessively long variable names like $queryGeneratorParents. Keep variable name length under 20.
            Open

                            $queryGeneratorParents = new \App\QueryGenerator('ModComments');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

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

            class ModComments_Record_Model extends Vtiger_Record_Model

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

                public function setId($id)
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            The class ModComments_Record_Model is not named in CamelCase.
            Open

            class ModComments_Record_Model extends Vtiger_Record_Model
            {
                /** @var \Vtiger_Record_Model Commentator record model instance. */
                private $commentatorModel;
            
            
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            CamelCaseClassName

            Since: 0.2

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

            Example

            class class_name {
            }

            Source

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

                    $id = $this->get('modcommentsid');
            Severity: Minor
            Found in modules/ModComments/models/Record.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

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

                    $id = $this->get('modcommentsid');

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

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

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

                        $forSave['vtiger_modcomments']['userid'] = App\User::getCurrentUserRealId();

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

                 */

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

                    $parentModel = null;

            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

                private $commentatorModel;

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

                {

            Line exceeds 120 characters; contains 184 characters
            Open

                        return $this->privileges['isEditable'] = \App\User::getCurrentUserRealId() === (int) $this->get('userid') && parent::isEditable() && $this->isPermitted('EditableComments');

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

                public function getParentCommentModel(): ?Vtiger_Record_Model

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

                        return $this->parentModel;

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

                    } elseif (($commentedBy = $this->get('assigned_user_id')) && \App\User::isExists($commentedBy, 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

                public function setId($id)

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

                }

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

                    return $this->privileges['isEditable'];

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

                 * @return string - url

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

                 *

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

                {

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

                }

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

                    if (isset($this->parentModel)) {

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

                    return $this->parentModel = $parentModel;

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

                public function getCommentedByModel(): ?Vtiger_Record_Model

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

                    }

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

                    return $this->commentatorModel;

            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 (!isset($this->privileges['isEditable'])) {

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

                 */

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

                    $forSave = parent::getValuesForSave();

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

                }

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

                /** @var \Vtiger_Record_Model Commentator record model instance. */

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

                    $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

                    if ($this->get('assigned_user_id')) {

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

                    return $this->get('modcommentsid');

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

                    return $this->set('modcommentsid', $id);

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

                /**

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

                 *

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

                    return $forSave;

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

                 * Function returns the parent Comment Model.

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

                {

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

                public function getCommentatorName(): string

            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

                        $this->commentatorModel = Vtiger_Record_Model::getInstanceById($customer, 'Contacts');

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

                 * Prepare value to 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

                    if (isset($this->parentCommentModel)) {

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

                    return $this->parentCommentModel = $parentCommentModel;

            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 string

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

                {

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

                /** @var \Vtiger_Record_Model Parent record model instance. */

            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 returns url to get child comments.

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

                 * Get commentator image.

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

                    if (($commentator = $this->getCommentedByModel()) && ($imagePath = $commentator->getImage())) {

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

                /** {@inheritdoc} */

            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

                    $parentCommentModel = null;

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

                    if ($recordId = $this->get('parent_comments')) {

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

                    }

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

                        $parentModel = Vtiger_Record_Model::getInstanceById($parentRecordId);

            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 returns the commentator Model (Users Model).

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

                    if ($customer = $this->get('customer')) {

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

                /** @var \Vtiger_Record_Model Parent comment record model instance. */

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

                        return $this->get('id');

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

                /** {@inheritdoc} */

            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 (isset($this->commentatorModel)) {

            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\Layout::getImagePath('MailConverterComment.png');

            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

                /** {@inheritdoc} */

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

                    if (empty($id)) {

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

                    return $this->getDetailViewUrl() . '&mode=showChildComments';

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

                        return $this->parentCommentModel;

            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

                 * Get commentator name.

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

                private $parentCommentModel;

            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

                        $parentCommentModel = Vtiger_Record_Model::getInstanceById($recordId, 'ModComments');

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

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

                public function getId()

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

                public function isEditable(): bool

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

                }

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

                    }

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

                    if ($parentRecordId = $this->get('related_to')) {

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

                public function getParentRecordModel(): ?Vtiger_Record_Model

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

                {

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

                }

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

                 * @return array|string

            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 (1 == $this->get('from_mailconverter')) {

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

                        return $imagePath;

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

                private $parentModel;

            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 returns the parent Record Model(Contacts, Accounts etc).

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

                    }

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

                        return $this->commentatorModel;

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

                }

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

                        return $this->privileges['isEditable'] = \App\User::getCurrentUserRealId() === (int) $this->get('userid') && parent::isEditable() && $this->isPermitted('EditableComments');

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

                    if (empty($forSave['vtiger_modcomments']['userid'])) {

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

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

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

                        $this->commentatorModel = Vtiger_Record_Model::getInstanceById($commentedBy, 'Users');

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

                public function getImage()

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

                        $label = $label ? "$contact ($label)" : $label;

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

                 *

            Line exceeds 120 characters; contains 131 characters
            Open

                    if (\count($hierarchy) > $requireCount && ($query = \App\ModuleHierarchy::getQueryRelatedRecords($parentId, $hierarchy))) {

            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

                    $parentCommentId = $this->getId();

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

                    //Condition are directly added as query_generator transforms the

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

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

                 * Function returns all the parent comments model.

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

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));

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

                    $recordInstances = [];

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

                        $recordInstances[] = $recordInstance;

            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 getCommentsCount(int $recordId): int

            Line exceeds 120 characters; contains 127 characters
            Open

                    $queryGenerator->addNativeCondition(['parent_comments' => $parentCommentId, 'related_to' => $this->get('related_to')]);

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

                 * Returns parent comment models for a comment.

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

                 */

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

                    return $this->get('createdtime');

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

                /**

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

                    $queryGenerator->setFields([]);

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

                    $queryGenerator->addNativeCondition(['related_to' => $recordId]);

            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 string

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

                 *

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

                    $requireCount = false === $moduleLevel || \in_array($moduleLevel, $hierarchy) ? 1 : 0;

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

                 * Function returns all the child comment count.

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

                    $queryGenerator->addNativeCondition(['parent_comments' => $recordId, 'related_to' => $this->get('related_to')]);

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

                    return $queryGenerator->createQuery()->count();

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

                 * Function returns all the comment count.

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

                    $queryGenerator->setSourceRecord($recordId);

            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[]               $hierarchy

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

                 * @param Vtiger_Paging_Model $pagingModel

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

                        $query->limit($pagingModel->getPageLimit())->offset($pagingModel->getStartIndex());

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

                        $recordInstance = new self();

            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

                 * @return int

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

                    $queryGenerator->setFields([]);

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

                    if (empty($parentCommentId)) {

            Line exceeds 120 characters; contains 126 characters
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));

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

                    $commentId = $this->getId();

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

                    $parentCommentId = explode('::', $this->get('parents'))[0];

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

                 * Function returns the commented time.

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

                public function getModifiedTime()

            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 126 characters
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));

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

                    }

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

                    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

                    return $queryGenerator->createQuery()->count('modcommentsid');

            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

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));

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

                {

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

                /**

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

                    return $this->get('modifiedtime');

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

                        if ($requireCount) {

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

                    $recordId = $this->getId();

            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

                    } elseif ($requireCount) {

            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

                        return 0;

            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

                        $recordInstances[] = $recordInstance;

            Line exceeds 120 characters; contains 126 characters
            Open

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));

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

                    $dataReader = $queryGenerator->createQuery()->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

                    $queryGenerator = new \App\QueryGenerator('ModComments');

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

                    $moduleLevel = \App\ModuleHierarchy::getModuleLevel($moduleName);

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

                    $queryGenerator->addNativeCondition($where);

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

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

                    $queryGenerator->setSourceRecord($recordId);

            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

                }

            Line exceeds 120 characters; contains 125 characters
            Open

                    $queryGenerator->addNativeCondition(['modcommentsid' => $parentCommentId, 'related_to' => $this->get('related_to')]);

            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 returns the commented time.

            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 = ['related_to' => $parentId];

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

                public function getChildCommentsCount(): 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

                    $queryGenerator = new \App\QueryGenerator('ModComments');

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

                    $queryGenerator->setFields(array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']));

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

                    return $recordInstances;

            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($commentId) || empty($parentCommentId)) {

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

                    $recordInstances = [];

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

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

                public static function getAllParentComments(int $parentId, string $moduleName, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)

            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

                    $query = $queryGenerator->createQuery()->orderBy(['vtiger_crmentity.createdtime' => SORT_DESC]);

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

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

                 * @return ModComment_Record_Model[]

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

                 */

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

                public function getChildComments()

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

            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 \ModComments_Record_Model[]

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

                    $dataReader = $query->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

                    $queryGenerator = new \App\QueryGenerator('ModComments');

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

                    $queryGenerator = new \App\QueryGenerator('ModComments');

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

                 * Returns child comments models for a comment.

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

                    $queryGenerator = new \App\QueryGenerator('ModComments');

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

                        $label = $this->getDisplayValue('assigned_user_id');

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

                 * @param string              $moduleName

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

                    $queryGenerator->setSourceRecord($parentId);

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

                        $where = ['related_to' => 0];

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

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

                    }

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

                        $recordInstance->setData($row)->setModuleFromInstance($queryGenerator->getModuleModel());

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

                 *

            Line exceeds 120 characters; contains 146 characters
            Open

                public static function getAllParentComments(int $parentId, string $moduleName, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)

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

                    if (\count($hierarchy) > $requireCount && ($query = \App\ModuleHierarchy::getQueryRelatedRecords($parentId, $hierarchy))) {

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

                        $where = ['related_to' => (new \App\Db\Query())->select(['id'])->from(['temp_query' => $query])];

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

                        $recordInstance->setData($row)->setModuleFromInstance($queryGenerator->getModuleModel());

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

                /**

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

                        $recordInstance = new self();

            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

                 * @return string

            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 = $queryGenerator->createQuery()->createCommand()->query();

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

                    $recordInstances = [];

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

                 * @return ModComment_Record_Model[]

            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

                    if ($this->get('customer') && ($contact = $this->getDisplayValue('customer'))) {

            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->union((new \App\Db\Query())->select([new \yii\db\Expression($parentId)]));

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

                    $queryGenerator->addNativeCondition(['parent_comments' => 0]);

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

                    if ($pagingModel && 0 !== $pagingModel->get('limit')) {

            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

                    //reference field and searches their entity names

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

                    $queryGenerator->addNativeCondition(['parent_comments' => $parentCommentId, 'related_to' => $this->get('related_to')]);

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

                public function getParentComments()

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

                    }

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

                    $queryGenerator->addNativeCondition(['modcommentsid' => $parentCommentId, 'related_to' => $this->get('related_to')]);

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

                 * @return \ModComments_Record_Model[]

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

                    $requireCount = 0;

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

                    $moduleLevel = \App\ModuleHierarchy::getModuleLevel($moduleName);

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

                            $queryGeneratorParents->setFields($fields);

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

                                $parentQuery->limit($pagingModel->getPageLimit())->offset($pagingModel->getStartIndex());

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

                /**

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

                            'dataUrl' => 'index.php?module=' . $this->getModuleName() . '&action=State&state=Archived&sourceView=List&record=' . $this->getId(),

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

                public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)

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

                        $where[] = ['related_to' => $parentId];

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

                    if ($pagingModel && 0 !== $pagingModel->get('limit')) {

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

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

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

                                $commentsId[] = $parentTempId;

            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

                    if (false === $moduleLevel || \in_array($moduleLevel, $hierarchy)) {

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

                    $queryGenerator->addNativeCondition($where);

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

                        $query->limit($pagingModel->getPageLimit())->offset($pagingModel->getStartIndex());

            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

                            } else {

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

                            'title' => \App\Language::translate('LBL_ARCHIVE_RECORD'),

            Line exceeds 120 characters; contains 148 characters
            Open

                            'dataUrl' => 'index.php?module=' . $this->getModuleName() . '&action=State&state=Archived&sourceView=List&record=' . $this->getId(),

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

                            'linkclass' => 'btn-md m-0 px-1 py-0 js-action-confirm',

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

                            'linkclass' => 'btn-md text-danger m-0 px-1 py-0 js-action-confirm',

            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 mixed               $moduleName

            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

                                $commentsId[] = $row['id'];

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

                        }

            Line exceeds 120 characters; contains 173 characters
            Open

                public static function getSearchComments(int $parentId, $moduleName, string $searchValue, bool $isWidget, array $hierarchy = [], Vtiger_Paging_Model $pagingModel = null)

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

                    $fields = array_merge(array_keys(\App\Field::getModuleFieldInfosByPresence('ModComments')), ['id']);

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

                    $queryGenerator->setSourceRecord($parentId);

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

                    $query = $queryGenerator->createQuery()->orderBy(['vtiger_crmentity.createdtime' => SORT_DESC]);

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

                    if ($this->privilegeToArchive()) {

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

                            'linkdata' => ['confirm' => \App\Language::translate('LBL_ARCHIVE_RECORD_DESC'), 'source-view' => 'DetailTab'],

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

                            'linkdata' => ['confirm' => \App\Language::translate('LBL_MOVE_TO_TRASH_DESC'), 'source-view' => 'DetailTab'],

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

                    $queryGenerator->addNativeCondition(['like', 'commentcontent', '%' . $searchValue . '%', false]);

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

                            'showLabel' => false,

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

                            'title' => \App\Language::translate('LBL_MOVE_TO_TRASH'),

            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 bool                $isWidget

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

                    if ($isWidget) {

            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 the list view actions for the comment.

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

                    if ($this->privilegeToMoveToTrash()) {

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

                            'linkicon' => 'fas fa-trash-alt',

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

                            'showLabel' => false,

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

                 * @param string              $searchValue

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

                    }

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

                        $commentsId = [];

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

                            'linkicon' => 'fas fa-archive',

            Line exceeds 120 characters; contains 145 characters
            Open

                            'dataUrl' => 'index.php?module=' . $this->getModuleName() . '&action=State&state=Trash&sourceView=List&record=' . $this->getId(),

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

                        $links[] = $link;

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

                 * @param int                 $parentId

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

                    $queryGenerator = new \App\QueryGenerator('ModComments');

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

                        $where[] = ['related_to' => (new \App\Db\Query())->select(['id'])->from(['temp_query' => $query])];

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

                            if (!empty($parentTempId) && !$isWidget) {

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

                    $links = [];

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

                        $links[] = Vtiger_Link_Model::getInstanceFromValues([

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

                            'linklabel' => 'LBL_ARCHIVE_RECORD',

            Line exceeds 120 characters; contains 127 characters
            Open

                            'linkdata' => ['confirm' => \App\Language::translate('LBL_ARCHIVE_RECORD_DESC'), 'source-view' => 'DetailTab'],

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

                        $recordInstance = new self();

            Line exceeds 120 characters; contains 131 characters
            Open

                    if (\count($hierarchy) > $requireCount && ($query = \App\ModuleHierarchy::getQueryRelatedRecords($parentId, $hierarchy))) {

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

                        }

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

                            $parentTempId = strstr($row['parents'], '::', true) ?: $row['parents'];

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

                        if (!empty($commentsId)) {

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

                                $recordInstances[] = $recordInstance;

            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 Vtiger_Link_Model[] - Associate array of Vtiger_Link_Model instances

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

                {

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

                        ]);

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

                 * @param int[]               $hierarchy

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

                        $requireCount = 1;

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

                            $recordInstances[] = $recordInstance;

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

                            $dataReaderParents = $parentQuery->createCommand()->query();

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

                                $recordInstance->setData($row)->setModuleFromInstance($queryGeneratorParents->getModuleModel());

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

                    }

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

                        $links[] = Vtiger_Link_Model::getInstanceFromValues([

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

                 * @param Vtiger_Paging_Model $pagingModel

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

                    $where = ['or'];

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

                            $queryGeneratorParents->addNativeCondition(['in', 'modcommentsid', array_unique($commentsId)], false);

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

                            $parentQuery = $queryGeneratorParents->createQuery();

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

                            if ($pagingModel && 0 !== $pagingModel->get('limit')) {

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

                    }

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

                            'dataUrl' => 'index.php?module=' . $this->getModuleName() . '&action=State&state=Trash&sourceView=List&record=' . $this->getId(),

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

                    return $links;

            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 (\count($hierarchy) > $requireCount && ($query = \App\ModuleHierarchy::getQueryRelatedRecords($parentId, $hierarchy))) {

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

                    $recordInstances = [];

            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

                            $queryGeneratorParents = new \App\QueryGenerator('ModComments');

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

                    return $recordInstances;

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

                            'style' => empty($stateColors['Archived']) ? '' : "color: {$stateColors['Archived']};",

            Line exceeds 120 characters; contains 126 characters
            Open

                            'linkdata' => ['confirm' => \App\Language::translate('LBL_MOVE_TO_TRASH_DESC'), 'source-view' => 'DetailTab'],

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

                    return $recordInstances;

            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

                            $recordInstance->setData($row)->setModuleFromInstance($queryGenerator->getModuleModel());

            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 = $dataReaderParents->read()) {

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

                                $recordInstance = new self();

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

                 */

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

                            'linklabel' => 'LBL_MOVE_TO_TRASH',

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

                        $recordInstances[] = $recordInstance;

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

                    $queryGenerator->setFields($fields);

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

                }

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

                    $stateColors = App\Config::search('LIST_ENTITY_STATE_COLOR');

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

                    if ($link = \App\Fields\ServerAccess::getLinks($this, 'ModComments')) {

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

                        $recordInstance->setData($row)->setModuleFromInstance($queryGenerator->getModuleModel());

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

                 * Function returns all the parent comments model.

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

                 */

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

                            $recordInstance = new self();

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

                public function getCommentLinks()

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

            class ModComments_Record_Model extends Vtiger_Record_Model

            There are no issues that match your filters.

            Category
            Status