YetiForceCompany/YetiForceCRM

View on GitHub
api/webservice/WebservicePremium/Privilege.php

Summary

Maintainability
D
2 days
Test Coverage
D
65%

Function isPermitted has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)
    {
        if (!$userId) {
            $user = \App\User::getCurrentUserModel();
        } else {
Severity: Minor
Found in api/webservice/WebservicePremium/Privilege.php - About 1 day to fix

Cognitive Complexity

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

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

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

Further reading

Method isPermitted has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)
    {
        if (!$userId) {
            $user = \App\User::getCurrentUserModel();
        } else {
Severity: Major
Found in api/webservice/WebservicePremium/Privilege.php - About 4 hrs to fix

    Avoid too many return statements within this method.
    Open

                            return true;
    Severity: Major
    Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return true;
      Severity: Major
      Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return false;
        Severity: Major
        Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return false;
          Severity: Major
          Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                        return true;
            Severity: Major
            Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return true;
              Severity: Major
              Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return true;
                Severity: Major
                Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return false;
                  Severity: Major
                  Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $permission;
                    Severity: Major
                    Found in api/webservice/WebservicePremium/Privilege.php - About 30 mins to fix

                      The method isPermitted() has an NPath complexity of 12636000. The configured NPath complexity threshold is 200.
                      Open

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)
                          {
                              if (!$userId) {
                                  $user = \App\User::getCurrentUserModel();
                              } else {

                      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 isPermitted() has 108 lines of code. Current threshold is set to 100. Avoid really long methods.
                      Open

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)
                          {
                              if (!$userId) {
                                  $user = \App\User::getCurrentUserModel();
                              } else {

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

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)
                          {
                              if (!$userId) {
                                  $user = \App\User::getCurrentUserModel();
                              } else {

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

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)

                      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

                      Reduce the number of returns of this function 13, down to the maximum allowed 3.
                      Open

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)

                      Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                      Noncompliant Code Example

                      With the default threshold of 3:

                      function myFunction(){ // Noncompliant as there are 4 return statements
                        if (condition1) {
                          return true;
                        } else {
                          if (condition2) {
                            return false;
                          } else {
                            return true;
                          }
                        }
                        return false;
                      }
                      

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

                      class Privilege
                      {
                          /**
                           * Permissions based on user.
                           */

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

                                  throw new \Api\Core\Exception('No permission to X-PARENT-ID', 403);

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

                                  $hierarchy = new \Api\WebservicePremium\BaseModule\Hierarchy();

                      MissingImport

                      Since: 2.7.0

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

                      Example

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

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

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

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)

                      BooleanArgumentFlag

                      Since: 1.4.0

                      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                      Example

                      class Foo {
                          public function bar($flag = true) {
                          }
                      }

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

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

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)

                      BooleanArgumentFlag

                      Since: 1.4.0

                      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                      Example

                      class Foo {
                          public function bar($flag = true) {
                          }
                      }

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

                      Missing class import via use statement (line '71', column '15').
                      Open

                                      throw new \Api\Core\Exception('Invalid permissions ', 400);

                      MissingImport

                      Since: 2.7.0

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

                      Example

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

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

                      Avoid using static access to class '\App\Privilege' in method 'isPermitted'.
                      Open

                                  return \App\Privilege::checkPermission($moduleName, $actionName, $record, $userId);

                      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_Relation_Model' in method 'isPermitted'.
                      Open

                                  $relationModel = \Vtiger_Relation_Model::getInstanceById($relationId);

                      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\Request' in method 'getParentCrmId'.
                      Open

                              if (($parentId = (int) \App\Request::_getHeader('x-parent-id')) && $parentApiId !== $parentId) {

                      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 static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)
                          {
                              if (!$userId) {
                                  $user = \App\User::getCurrentUserModel();
                              } else {

                      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\Record' in method 'isPermitted'.
                      Open

                              $parentModule = \App\Record::getType($parentRecordId) ?? '';

                      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 '\Documents_Record_Model' in method 'isPermitted'.
                      Open

                                  foreach (\Documents_Record_Model::getReferenceModuleByDocId($record) as $parentModuleName) {

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

                                  $user = \App\User::getUserModel($userId);

                      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\Record' in method 'isPermitted'.
                      Open

                                      $parentRecordId = \App\Record::getParentRecord($user->get('permission_crmid'));

                      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\Record' in method 'getParentCrmId'.
                      Open

                                  $hierarchy->moduleName = \App\Record::getType($parentApiId);

                      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\Record' in method 'isPermitted'.
                      Open

                                              if (\App\Record::isExists($relRecordId, $relModuleName) && \App\Record::getType($relRecordId) === $relModuleName && \Vtiger_Record_Model::getInstanceById($relRecordId, $relModuleName)->get($referenceField->getName()) === $parentRecordId) {

                      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\Record' in method 'isPermitted'.
                      Open

                                              if (\App\Record::isExists($relRecordId, $relModuleName) && \App\Record::getType($relRecordId) === $relModuleName && \Vtiger_Record_Model::getInstanceById($relRecordId, $relModuleName)->get($referenceField->getName()) === $parentRecordId) {

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

                              } else {
                                  $user = \App\User::getUserModel($userId);
                              }

                      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_RelationListView_Model' in method 'isPermitted'.
                      Open

                                      $relationListView = \Vtiger_RelationListView_Model::getInstance($recordModel, $parentModuleName);

                      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 '73', column '42').
                      Open

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)
                          {
                              if (!$userId) {
                                  $user = \App\User::getCurrentUserModel();
                              } else {

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

                              if (0 === \App\ModuleHierarchy::getModuleLevel($moduleName)) {

                      StaticAccess

                      Since: 1.4.0

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

                      Example

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

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

                      Avoid using static access to class '\Vtiger_Module_Model' in method 'isPermitted'.
                      Open

                                          $relModuleModel = \Vtiger_Module_Model::getInstance($relModuleName);

                      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\Privilege' in method 'isPermitted'.
                      Open

                                      return \App\Privilege::checkPermission($moduleName, $actionName, $record, $userId);

                      StaticAccess

                      Since: 1.4.0

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

                      Example

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

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

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

                              foreach (array_keys(\App\Relation::getByModule($parentModule, true, $moduleName)) as $relationId) {

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

                                  $relationModel->set('parentRecord', \Vtiger_Record_Model::getInstanceById($parentRecordId, $parentModule));

                      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 '\Api\Core\Module' in method 'isPermitted'.
                      Open

                              if ('ModComments' !== $moduleName && !($permissionFieldInfo = \Api\Core\Module::getApiFieldPermission($moduleName, $user->get('permission_app')))) {

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

                                  $user = \App\User::getCurrentUserModel();

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

                              $recordModel = \Vtiger_Record_Model::getInstanceById($record, $moduleName);

                      StaticAccess

                      Since: 1.4.0

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

                      Example

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

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

                      Avoid using static access to class '\App\Privilege' in method 'isPermitted'.
                      Open

                                          if (\App\Privilege::isPermitted($parentModuleName, 'DetailView', $id, $user->getId())) {

                      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 '169', column '8').
                      Open

                          public static function getParentCrmId(\App\User $user): int
                          {
                              $contactId = $user->get('permission_crmid');
                              $parentApiId = \App\Record::getParentRecord($contactId);
                              if (($parentId = (int) \App\Request::_getHeader('x-parent-id')) && $parentApiId !== $parentId) {

                      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\Privilege' in method 'isPermitted'.
                      Open

                              if (!\App\Privilege::checkPermission($moduleName, $actionName, $record, $userId)) {

                      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\Record' in method 'getParentCrmId'.
                      Open

                              $parentApiId = \App\Record::getParentRecord($contactId);

                      StaticAccess

                      Since: 1.4.0

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

                      Example

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

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

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

                              if (empty($record) || !$user->has('permission_type')) {

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

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

                      Noncompliant Code Example

                      With the default threshold of 3:

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

                      Compliant Solution

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

                      Exceptions

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

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

                              if ('ModComments' !== $moduleName && !$recordModel->get($permissionFieldInfo['fieldname'])) {

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

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

                      Noncompliant Code Example

                      With the default threshold of 3:

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

                      Compliant Solution

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

                      Exceptions

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

                      Call to method readColumn from undeclared class \yii\db\DataReader
                      Open

                                      while ($id = $dataReader->readColumn(0)) {

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

                              $contactId = $user->get('permission_crmid');

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

                                  $user = \App\User::getCurrentUserModel();

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

                                  $user = \App\User::getUserModel($userId);

                      Argument 1 (recordId) is ?int but \App\Record::getType() takes int defined at /code/app/Record.php:279
                      Open

                              $parentModule = \App\Record::getType($parentRecordId) ?? '';

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

                                  $queryGenerator->clearFields()->setFields(['id'])->addCondition('id', $record, 'e');

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

                                      $relationListView->getQueryGenerator()->setFields(['id'])->setLimit(10)->permissions = false;

                      Argument 1 (recordId) is ?int but \Vtiger_Record_Model::getInstanceById() takes int defined at /code/modules/Vtiger/models/Record.php:763
                      Open

                                  $relationModel->set('parentRecord', \Vtiger_Record_Model::getInstanceById($parentRecordId, $parentModule));

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

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

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

                                  $hierarchy->setAllUserData(['crmid' => $contactId, 'type' => $user->get('permission_type')]);

                      Reference to instance property permissions from undeclared class \App\QueryGenerator
                      Open

                                  $queryGenerator->permissions = false;

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

                                  if ($queryGenerator->createQuery()->exists()) {

                      Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
                      Open

                          public static function getParentCrmId(\App\User $user): int

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

                                      while ($id = $dataReader->readColumn(0)) {

                      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

                              switch ($user->get('permission_type')) {

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

                                      $parentRecordId = static::getParentCrmId($user);

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

                          const ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY = 3;

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

                           * Permissions based on user.

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

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

                          public static function isPermitted(string $moduleName, $actionName = null, $record = false, $userId = false)

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

                           * Function to check permission for a Module/Action/Record.

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

                              $userId = $user->getId();

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

                              if (empty($record) || !$user->has('permission_type')) {

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

                           * @throws \Api\Core\Exception

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

                                      $parentRecordId = \App\Record::getParentRecord($user->get('permission_crmid'));

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

                                      throw new \Api\Core\Exception('Invalid permissions ', 400);

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

                          const USER_PERMISSIONS = 1;

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

                           * All related records of account assigned directly to contact and accounts from hierarchy.

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

                           * @param bool|int $record

                      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 bool

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

                                  case self::ACCOUNTS_RELATED_RECORDS:

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

                                  default:

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

                              if (!\App\Privilege::checkPermission($moduleName, $actionName, $record, $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

                           */

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

                                  $user = \App\User::getUserModel($userId);

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

                                  case self::ACCOUNTS_RELATED_RECORDS_IN_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

                                      return \App\Privilege::checkPermission($moduleName, $actionName, $record, $userId);

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

                                      break;

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

                          const ACCOUNTS_RELATED_RECORDS = 2;

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

                           * All related records of account assigned directly to contact and accounts lower in 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

                           * @param string   $moduleName

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

                           */

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

                          {

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

                           * @param string   $actionName

                      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

                              }

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

                                  return \App\Privilege::checkPermission($moduleName, $actionName, $record, $userId);

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

                                  return false;

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

                              }

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

                           */

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

                           *

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

                                  $user = \App\User::getCurrentUserModel();

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

                                      break;

                      Line exceeds 120 characters; contains 156 characters
                      Open

                              if ('ModComments' !== $moduleName && !($permissionFieldInfo = \Api\Core\Module::getApiFieldPermission($moduleName, $user->get('permission_app')))) {

                      Line exceeds 120 characters; contains 162 characters
                      Open

                                  \App\Privilege::$isPermittedLevel = "FIELD_PERMISSION_NO {$permissionFieldInfo['fieldname']}: {$recordModel->get($permissionFieldInfo['fieldname'])}";

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

                                  $queryGenerator = $relationModel->getQuery();

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

                                  foreach (\Documents_Record_Model::getReferenceModuleByDocId($record) as $parentModuleName) {

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

                              return false;

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

                          /**

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

                          public static function getParentCrmId(\App\User $user): int

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

                              if (($parentId = (int) \App\Request::_getHeader('x-parent-id')) && $parentApiId !== $parentId) {

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

                              }

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

                              if (0 === \App\ModuleHierarchy::getModuleLevel($moduleName)) {

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

                                  $permission = $parentRecordId === $record;

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

                              }

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

                                      $relationListView->setFields([]);

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

                                  \App\Privilege::$isPermittedLevel = "FIELD_PERMISSION_NO {$permissionFieldInfo['fieldname']}: {$recordModel->get($permissionFieldInfo['fieldname'])}";

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

                                  return false;

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

                                          return true;

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

                                  }

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

                                  $queryGenerator->permissions = false;

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

                                      foreach ($fieldModel->getReferenceList() as $relModuleName) {

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

                                          $relModuleModel = \Vtiger_Module_Model::getInstance($relModuleName);

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

                              }

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

                                      $relationListView = \Vtiger_RelationListView_Model::getInstance($recordModel, $parentModuleName);

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

                              $parentApiId = \App\Record::getParentRecord($contactId);

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

                                  $hierarchy->findId = $parentId;

                      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 ($queryGenerator->createQuery()->exists()) {

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

                              }

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

                              }

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

                                  case self::ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_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

                                  $queryGenerator->clearFields()->setFields(['id'])->addCondition('id', $record, 'e');

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

                                          if (\App\Privilege::isPermitted($parentModuleName, 'DetailView', $id, $user->getId())) {

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

                                  if (isset($records[$parentId])) {

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

                                  \App\Privilege::$isPermittedLevel = 'RECORD_HIERARCHY_LEVEL_' . ($permission ? 'YES' : 'NO');

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

                              $recordModel = \Vtiger_Record_Model::getInstanceById($record, $moduleName);

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

                                          foreach ($relModuleModel->getReferenceFieldsForModule($parentModule) as $referenceField) {

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

                              \App\Privilege::$isPermittedLevel = 'ALL_PERMISSION_NO';

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

                                          \App\Privilege::$isPermittedLevel = 'RECORD_RELATED_YES';

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

                           *

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

                                                  \App\Privilege::$isPermittedLevel = $moduleName . '_RELATED_SL_YES';

                      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

                                  $hierarchy = new \Api\WebservicePremium\BaseModule\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

                           * All records of account assigned directly to contact.

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

                          /**

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

                                  case self::USER_PERMISSIONS:

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

                              }

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

                                                  return true;

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

                                              }

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

                                          }

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

                                  $hierarchy->moduleName = \App\Record::getType($parentApiId);

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

                                  return false;

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

                              }

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

                                      if (!$fieldModel->isActiveField() || $recordModel->isEmpty($fieldModel->getName())) {

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

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

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

                                      while ($id = $dataReader->readColumn(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

                          /**

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

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

                                  return false;

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

                                  \App\Privilege::$isPermittedLevel = 'FIELD_PERMISSION_NOT_EXISTS';

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

                                      \App\Privilege::$isPermittedLevel = $moduleName . '_RELATED_YES';

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

                              }

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

                                      return true;

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

                              }

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

                                      }

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

                              }

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

                                  $relationModel = \Vtiger_Relation_Model::getInstanceById($relationId);

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

                              if ('Documents' === $moduleName) {

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

                          }

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

                                              return true;

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

                           * @param \App\User $user

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

                                          }

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

                              $moduleModel = $recordModel->getModule();

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

                              if (\in_array($moduleName, ['Products', 'Services'])) {

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

                                      if ($recordModel->get($referenceField->getName()) === $parentRecordId) {

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

                                          continue;

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

                                          if ('Users' === $relModuleName || $relModuleName === $parentModule || $relModuleName === $moduleName) {

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

                                              continue;

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

                                  }

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

                              if ('ModComments' !== $moduleName && !$recordModel->get($permissionFieldInfo['fieldname'])) {

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

                                  foreach ($fieldsForParent as $referenceField) {

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

                                  \App\Privilege::$isPermittedLevel = 'RECORD_RELATED_NO';

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

                                  }

                      Line exceeds 120 characters; contains 263 characters
                      Open

                                              if (\App\Record::isExists($relRecordId, $relModuleName) && \App\Record::getType($relRecordId) === $relModuleName && \Vtiger_Record_Model::getInstanceById($relRecordId, $relModuleName)->get($referenceField->getName()) === $parentRecordId) {

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

                           * Gets parent 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

                                  $hierarchy->setAllUserData(['crmid' => $contactId, 'type' => $user->get('permission_type')]);

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

                                  $records = $hierarchy->get();

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

                                  \App\Privilege::$isPermittedLevel = $moduleName . '_SPECIAL_PERMISSION_YES';

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

                                  return true;

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

                                      $relRecordId = $recordModel->get($fieldModel->getName());

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

                                          }

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

                           *

                      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

                                  throw new \Api\Core\Exception('No permission to X-PARENT-ID', 403);

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

                              return $parentApiId;

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

                                  return $permission;

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

                              $fieldsForParent = $moduleModel->getReferenceFieldsForModule($parentModule);

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

                              foreach (array_keys(\App\Relation::getByModule($parentModule, true, $moduleName)) as $relationId) {

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

                              if ($fields = $moduleModel->getFieldsByReference()) {

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

                                  foreach ($fields as $fieldModel) {

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

                                              \App\Privilege::$isPermittedLevel = "PERMISSION_{$parentModuleName}_YES-{$id}";

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

                                      return $parentId;

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

                          }

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

                          const ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY = 4;

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

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

                              if ('ModComments' !== $moduleName && !($permissionFieldInfo = \Api\Core\Module::getApiFieldPermission($moduleName, $user->get('permission_app')))) {

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

                              $parentModule = \App\Record::getType($parentRecordId) ?? '';

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

                                  $relationModel->set('parentRecord', \Vtiger_Record_Model::getInstanceById($parentRecordId, $parentModule));

                      Line exceeds 120 characters; contains 123 characters
                      Open

                                          if ('Users' === $relModuleName || $relModuleName === $parentModule || $relModuleName === $moduleName) {

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

                                              if (\App\Record::isExists($relRecordId, $relModuleName) && \App\Record::getType($relRecordId) === $relModuleName && \Vtiger_Record_Model::getInstanceById($relRecordId, $relModuleName)->get($referenceField->getName()) === $parentRecordId) {

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

                                      $relationListView->getQueryGenerator()->setFields(['id'])->setLimit(10)->permissions = false;

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

                              $contactId = $user->get('permission_crmid');

                      There are no issues that match your filters.

                      Category
                      Status