YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
B
6 hrs
Test Coverage
F
3%

Function importTaskMethod has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function importTaskMethod(array &$method, array &$messages)
    {
        $scriptData = base64_decode($method['script_content']);
        $functionPath = $method['function_path'];
        if (!$this->checkPathForImportMethod($functionPath)) {
Severity: Minor
Found in modules/Settings/Workflows/models/Module.php - About 1 hr to fix

Cognitive Complexity

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

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

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

Further reading

Method importTaskMethod has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function importTaskMethod(array &$method, array &$messages)
    {
        $scriptData = base64_decode($method['script_content']);
        $functionPath = $method['function_path'];
        if (!$this->checkPathForImportMethod($functionPath)) {
Severity: Minor
Found in modules/Settings/Workflows/models/Module.php - About 1 hr to fix

    Function updateActionsSequence has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function updateActionsSequence(int $wfIdToMove, int $workflowBeforeId, string $moduleName): void
        {
            if ($workflowBeforeId !== $wfIdToMove) {
                $db = \App\Db::getInstance();
                $caseSequence = 'CASE';
    Severity: Minor
    Found in modules/Settings/Workflows/models/Module.php - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method importWorkflow has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function importWorkflow(array $data)
        {
            $db = App\Db::getInstance();
            $dbCommand = App\Db::getInstance()->createCommand();
            $dbCommand->insert($this->getBaseTable(), $data['fields'])->execute();
    Severity: Minor
    Found in modules/Settings/Workflows/models/Module.php - About 1 hr to fix

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

          public function importWorkflow(array $data)
          {
              $db = App\Db::getInstance();
              $dbCommand = App\Db::getInstance()->createCommand();
              $dbCommand->insert($this->getBaseTable(), $data['fields'])->execute();
      Severity: Minor
      Found in modules/Settings/Workflows/models/Module.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

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

          public function getListFields(): array
          {
              if (!property_exists($this, 'listFieldModels')) {
                  $fields = $this->listFields;
                  $fieldObjects = [];
      Severity: Minor
      Found in modules/Settings/Workflows/models/Module.php - About 35 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          public function importTaskMethod(array &$method, array &$messages)
          {
              $scriptData = base64_decode($method['script_content']);
              $functionPath = $method['function_path'];
              if (!$this->checkPathForImportMethod($functionPath)) {

      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

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

                  $emm = new VTEntityMethodManager();

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

                      $taskManager = new VTTaskManager();

      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 '175', column '38').
      Open

                          $fieldObjects[$fieldName] = new \App\Base(['name' => $fieldName, 'label' => $fieldLabel, 'sort' => false]);

      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 '342', column '23').
      Open

                      'sequence' => new yii\db\Expression($caseSequence),

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

              $method = (new \App\Db\Query())->select(['workflowtasks_entitymethod_id', 'module_name', 'method_name', 'function_path', 'function_name'])->from('com_vtiger_workflowtasks_entitymethod')->where(['method_name' => $methodName])->one();

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

                  throw new \App\Exceptions\Security('ERR_NOT_ALLOWED_VALUE||function_path', 406);

      MissingImport

      Since: 2.7.0

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

      Example

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

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

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

                      throw new \App\Exceptions\Security('ERR_DIRECTORY_CANNOT_BE_CREATED||function_path', 406);

      MissingImport

      Since: 2.7.0

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

      Example

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

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

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

              $num = (new \App\Db\Query())

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

              $mem = new VTExpressionsManager();

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

                  throw new \App\Exceptions\Security('ERR_NOT_ALLOWED_VALUE||script_content', 406);

      MissingImport

      Since: 2.7.0

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

      Example

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

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

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

                      throw new \App\Exceptions\IllegalValue('ERR_SCRIPT_EXISTS_FUNCTION_NOT||function_path', 406);

      MissingImport

      Since: 2.7.0

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

      Example

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

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

      Missing class import via use statement (line '177', column '38').
      Open

                          $fieldObjects[$fieldName] = new \App\Base(['name' => $fieldName, 'label' => $fieldLabel]);

      MissingImport

      Since: 2.7.0

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

      Example

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

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

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

              return (new \App\Db\Query())->select(['workflow_id', 'summary'])

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

                      throw new \App\Exceptions\IllegalValue('ERR_FAILED_TO_SAVE_SCRIPT||function_path', 406);

      MissingImport

      Since: 2.7.0

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

      Example

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

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

      Avoid using static access to class 'App\Db' in method 'importWorkflow'.
      Open

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

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class '\App\Db' in method 'updateActionsSequence'.
      Open

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

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class '\vtlib\Module' in method 'checkPathForImportMethod'.
      Open

                  $returnVal = false !== \vtlib\Module::getInstance($match[1]);

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

          public function checkPathForImportMethod(string $path): bool
          {
              if ($returnVal = \preg_match('/^modules[\\\\|\\/]([A-Z][a-z,A-Z]+)[\\\\|\\/]workflows[\\\\|\\/][A-Z][a-z,A-Z]+\\.php$/', $path, $match)) {
                  //Check if the module exists
                  $returnVal = false !== \vtlib\Module::getInstance($match[1]);

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

                      } else {
                          $fieldObjects[$fieldName] = new \App\Base(['name' => $fieldName, 'label' => $fieldLabel]);
                      }

      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

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

              } else {
                  require_once $functionPath;
                  if (!method_exists($method['function_name'], $method['method_name'])) {
                      throw new \App\Exceptions\IllegalValue('ERR_SCRIPT_EXISTS_FUNCTION_NOT||function_path', 406);
                  }

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

              $moduleModels = Vtiger_Module_Model::getAll([0, 2]);

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

          public $baseTable = 'com_vtiger_workflows';

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

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

                      'sequence' => new yii\db\Expression($caseSequence),

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

                          $dbCommand->insert('com_vtiger_workflowtasks', ['workflow_id' => $workflowId, 'summary' => $task['summary']])->execute();

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

              $method = (new \App\Db\Query())->select(['workflowtasks_entitymethod_id', 'module_name', 'method_name', 'function_path', 'function_name'])->from('com_vtiger_workflowtasks_entitymethod')->where(['method_name' => $methodName])->one();

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

          public $listFields = ['summary' => 'Summary', 'module_name' => 'Module', 'execution_condition' => 'Execution Condition', 'all_tasks' => 'LBL_ALL_TASKS', 'active_tasks' => 'LBL_ACTIVE_TASKS'];

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

              $method = (new \App\Db\Query())->select(['workflowtasks_entitymethod_id', 'module_name', 'method_name', 'function_path', 'function_name'])->from('com_vtiger_workflowtasks_entitymethod')->where(['method_name' => $methodName])->one();

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

              $method = (new \App\Db\Query())->select(['workflowtasks_entitymethod_id', 'module_name', 'method_name', 'function_path', 'function_name'])->from('com_vtiger_workflowtasks_entitymethod')->where(['method_name' => $methodName])->one();

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

          public $baseIndex = 'workflow_id';

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

          public $listFields = ['summary' => 'Summary', 'module_name' => 'Module', 'execution_condition' => 'Execution Condition', 'all_tasks' => 'LBL_ALL_TASKS', 'active_tasks' => 'LBL_ACTIVE_TASKS'];

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

          public $listFields = ['summary' => 'Summary', 'module_name' => 'Module', 'execution_condition' => 'Execution Condition', 'all_tasks' => 'LBL_ALL_TASKS', 'active_tasks' => 'LBL_ACTIVE_TASKS'];

      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.

      Avoid unused parameters such as '$messages'.
      Open

          public function importTaskMethod(array &$method, array &$messages)

      UnusedFormalParameter

      Since: 0.2

      Avoid passing parameters to methods or constructors and then not using those parameters.

      Example

      class Foo
      {
          private function bar($howdy)
          {
              // $howdy is not used
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

              \App\Db::getInstance()->createCommand()->delete('com_vtiger_workflows', ['module_name' => $moduleInstance->name])->execute();

      Returning type array|array{id:string} but importWorkflow() is declared to return int
      Open

              return $messages;

      Expected an object instance when accessing an instance property, but saw an expression with type array|true
      Open

                          $taskObject->id = (int) $taskId;

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

              $num = (new \App\Db\Query())

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

                          $caseSequence .= " WHEN workflow_id = {$db->quoteValue($wfIdToMove)} THEN {$db->quoteValue($sequence)}";

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

              $dbCommand = App\Db::getInstance()->createCommand();

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

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

      Expected an object instance when accessing an instance property, but saw an expression with type array|true
      Open

                          $taskObject->workflowId = (int) $workflowId;

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

              $createCommand = \App\Db::getInstance()->createCommand();

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

              return (new \App\Db\Query())->select(['workflow_id', 'summary'])

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

              $method = (new \App\Db\Query())->select(['workflowtasks_entitymethod_id', 'module_name', 'method_name', 'function_path', 'function_name'])->from('com_vtiger_workflowtasks_entitymethod')->where(['method_name' => $methodName])->one();

      Reference to undeclared property \Settings_Workflows_Module_Model->listFieldModels
      Open

                  $this->listFieldModels = $fieldObjects;

      Reference to undeclared property \Settings_Workflows_Module_Model->listFieldModels
      Open

              return $this->listFieldModels;

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

                      $caseSequence .= " WHEN workflow_id = {$db->quoteValue($wfId)} THEN {$db->quoteValue($sequence)}";

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

                      'sequence' => new yii\db\Expression($caseSequence),

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

              $supportedModuleModels = [];

      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 Settings_Workflows_Module_Model extends Settings_Vtiger_Module_Model

      A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 18 and the first side effect is on line 12.
      Open

      <?php

      The class Settings_Workflows_Module_Model is not named in CamelCase.
      Open

      class Settings_Workflows_Module_Model extends Settings_Vtiger_Module_Model
      {
          /**
           * Base table name.
           *

      CamelCaseClassName

      Since: 0.2

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

      Example

      class class_name {
      }

      Source

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

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

      ShortVariable

      Since: 0.2

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

      Example

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

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

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

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

      ShortVariable

      Since: 0.2

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

      Example

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

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

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

              'module_name',

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

              'schtypeid',

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

              'schdayofmonth',

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

              1 => 'ON_FIRST_SAVE',

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

              3 => 'ON_EVERY_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

           * @return string - url

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

           * @var 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

              'summary',

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

              'conditions',

      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

          public $baseTable = 'com_vtiger_workflows';

      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

              6 => 'ON_SCHEDULE',

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

           *

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

          {

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

           * @return array

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

          {

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

              $supportedModuleModels = [];

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

          public static $allFields = [

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

          ];

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

           *

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

          public static $triggerTypes = [

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

           * Get create new record url.

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

              return 'index.php?module=Workflows&parent=Settings&view=Edit';

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

           *

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

           */

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

          public static function getSupportedModules()

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

           */

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

              //10 => 'ON_RELATED',

      Line exceeds 120 characters; contains 125 characters
      Open

              return "javascript:Settings_Workflows_List_Js.triggerCreate('index.php?module=Workflows&parent=Settings&view=Edit')";

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

              return 'index.php?module=Workflows&parent=Settings&view=Import';

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

           */

      Line exceeds 120 characters; contains 195 characters
      Open

          public $listFields = ['summary' => 'Summary', 'module_name' => 'Module', 'execution_condition' => 'Execution Condition', 'all_tasks' => 'LBL_ALL_TASKS', 'active_tasks' => 'LBL_ACTIVE_TASKS'];

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

              'filtersavedinnew',

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

           * Workflow triggers list.

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

          {

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

          /**

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

          /**

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

          public $listFields = ['summary' => 'Summary', 'module_name' => 'Module', 'execution_condition' => 'Execution Condition', 'all_tasks' => 'LBL_ALL_TASKS', 'active_tasks' => 'LBL_ACTIVE_TASKS'];

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

              'defaultworkflow',

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

              'schannualdates',

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

           * Module name.

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

              5 => 'ON_DELETE',

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

           *

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

           */

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

           * Base table name.

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

           *

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

           * @var array

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

          /**

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

          /**

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

           * @var string

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

              7 => 'MANUAL',

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

           */

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

           * Fields visible on list view 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

           * Function to get the url for create view of the module.

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

              'type',

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

           * Returns url for import view.

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

          public $name = 'Workflows';

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

                      $supportedModuleModels[$tabId] = $moduleModel;

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

          ];

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

          public static function getDefaultUrl()

      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 fields list.

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

              4 => 'ON_MODIFY',

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

              8 => 'TRIGGER',

      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 url

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

          public static function getImportViewUrl()

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

           * Get supported modules list.

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

              $moduleModels = Vtiger_Module_Model::getAll([0, 2]);

      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 $baseIndex = 'workflow_id';

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

              'execution_condition',

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

              'nexttrigger_time',

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

           * @var string

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

           * Base table index column name.

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

          /**

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

              'schtime',

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

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

          {

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

          }

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

          public static function getCreateRecordUrl()

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

           * @var array

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

              return "javascript:Settings_Workflows_List_Js.triggerCreate('index.php?module=Workflows&parent=Settings&view=Edit')";

      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

              9 => 'BLOCK_EDIT',

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

          /**

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

          }

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

              foreach ($moduleModels as $tabId => $moduleModel) {

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

                  if ($moduleModel->isWorkflowSupported()) {

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

           */

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

              'schdayofweek',

      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 array

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

              2 => 'ONCE',

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

           * Function to get the url for default view of the module.

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

              return 'index.php?module=Workflows&parent=Settings&view=List';

      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

                  $fields = $this->listFields;

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

              }

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

           * @param array $data

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

          public function importWorkflow(array $data)

      Line exceeds 120 characters; contains 141 characters
      Open

                          $dbCommand->insert('com_vtiger_workflowtasks', ['workflow_id' => $workflowId, 'summary' => $task['summary']])->execute();

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

           * @param array $messages array containing returned error messages

      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 (!\preg_match('/^<\\?php/', $scriptData)) {

      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 vtlib\ModuleBasic $moduleInstance

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

           */

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

                  foreach ($data['workflow_tasks'] as $task) {

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

                          $dbCommand->update('com_vtiger_workflowtasks', ['task' => serialize($taskObject)], ['task_id' => $taskId])->execute();

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

                      throw new \App\Exceptions\IllegalValue('ERR_FAILED_TO_SAVE_SCRIPT||function_path', 406);

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

                      throw new \App\Exceptions\IllegalValue('ERR_SCRIPT_EXISTS_FUNCTION_NOT||function_path', 406);

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

                      'module_name' => $method['module_name'],

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

           */

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

                  }

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

          /**

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

              $workflowId = $db->getLastInsertID('com_vtiger_workflows_workflow_id_seq');

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

              $method = (new \App\Db\Query())->select(['workflowtasks_entitymethod_id', 'module_name', 'method_name', 'function_path', 'function_name'])->from('com_vtiger_workflowtasks_entitymethod')->where(['method_name' => $methodName])->one();

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

              return $method;

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

          /**

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

                  $emm = new VTEntityMethodManager();

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

                  $fieldObjects = [];

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

                  $fieldsNoSort = ['module_name', 'execution_condition', 'all_tasks', 'active_tasks'];

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

                  $this->listFieldModels = $fieldObjects;

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

           * Imports workflow template xml file.

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

           * @return int workflow 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

                      $this->importTaskMethod($method, $messages);

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

                      $taskManager = new VTTaskManager();

      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 $methodName name of method

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

                      throw new \App\Exceptions\Security('ERR_DIRECTORY_CANNOT_BE_CREATED||function_path', 406);

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

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

          {

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

                      if (\in_array($fieldName, $fieldsNoSort)) {

      Line exceeds 120 characters; contains 127 characters
      Open

                          $fieldObjects[$fieldName] = new \App\Base(['name' => $fieldName, 'label' => $fieldLabel, 'sort' => 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

                      if (!empty($taskObject)) {

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

              return $messages;

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

          public static function exportTaskMethod($methodName)

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

              $method = (new \App\Db\Query())->select(['workflowtasks_entitymethod_id', 'module_name', 'method_name', 'function_path', 'function_name'])->from('com_vtiger_workflowtasks_entitymethod')->where(['method_name' => $methodName])->one();

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

                  $workflowsExists = file_exists(\dirname($functionPath));

      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

                      'function_name' => $method['function_name'],

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

          /**

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

          }

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

          public function getListFields(): array

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

           *

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

           *

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

                  foreach ($data['workflow_methods'] as $method) {

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

                          $taskObject->workflowId = (int) $workflowId;

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

              $functionPath = $method['function_path'];

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

                  throw new \App\Exceptions\Security('ERR_NOT_ALLOWED_VALUE||script_content', 406);

      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

                      $taskObject = $taskManager->unserializeTask(base64_decode($task['task']));

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

                      mkdir(\dirname($functionPath));

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

              return $supportedModuleModels;

      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

              $dbCommand = App\Db::getInstance()->createCommand();

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

                          $taskObject->id = (int) $taskId;

      Line exceeds 120 characters; contains 138 characters
      Open

                          $dbCommand->update('com_vtiger_workflowtasks', ['task' => serialize($taskObject)], ['task_id' => $taskId])->execute();

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

          /**

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

           */

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

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

                  require_once $functionPath;

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

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

                      'function_path' => $functionPath,

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

      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

              $messages = ['id' => $workflowId];

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

              if ($data['workflow_tasks']) {

      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

              $scriptData = base64_decode($method['script_content']);

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

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

           * Get supported triggers list.

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

                      }

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

           * Delete all worklflows associated with module.

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

           * @param array $method   array containing method data

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

                  ])->exists();

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

           *

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

                      } else {

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

                          $fieldObjects[$fieldName] = new \App\Base(['name' => $fieldName, 'label' => $fieldLabel]);

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

              \App\Db::getInstance()->createCommand()->delete('com_vtiger_workflows', ['module_name' => $moduleInstance->name])->execute();

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

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

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

              if (!empty($data['workflow_methods'])) {

      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 task method data

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

           */

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

              $num = (new \App\Db\Query())

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

          public static function getTriggerTypes()

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

              if (!property_exists($this, 'listFieldModels')) {

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

          public static function deleteForModule(vtlib\ModuleBasic $moduleInstance)

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

          {

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

                          $dbCommand->insert('com_vtiger_workflowtasks', ['workflow_id' => $workflowId, 'summary' => $task['summary']])->execute();

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

           * Returns infor for exporting of task method.

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

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

                  throw new \App\Exceptions\Security('ERR_NOT_ALLOWED_VALUE||function_path', 406);

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

              }

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

                  require_once 'modules/com_vtiger_workflow/VTEntityMethodManager.php';

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

           * Get expressions list.

      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

              $mem = new VTExpressionsManager();

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

                      include_once 'modules/com_vtiger_workflow/tasks/VTEmailTemplateTask.php';

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

           *

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

              $method['script_content'] = base64_encode(file_get_contents($method['function_path']));

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

           * Function that creates task method.

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

                  if (!method_exists($method['function_name'], $method['method_name'])) {

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

              }

      Line exceeds 120 characters; contains 133 characters
      Open

              \App\Db::getInstance()->createCommand()->delete('com_vtiger_workflows', ['module_name' => $moduleInstance->name])->execute();

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

           *

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

           * @return array

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

              $dbCommand->insert($this->getBaseTable(), $data['fields'])->execute();

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

          }

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

          }

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

                      include_once 'modules/com_vtiger_workflow/tasks/VTEntityMethodTask.php';

      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 importTaskMethod(array &$method, array &$messages)

      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 ($workflowsExists && is_file(\dirname($functionPath))) {

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

                  $emm->addEntityMethod($method['module_name'], $method['method_name'], $functionPath, $method['function_name']);

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

                  ->from('com_vtiger_workflowtasks_entitymethod')

      Line exceeds 120 characters; contains 123 characters
      Open

                  $emm->addEntityMethod($method['module_name'], $method['method_name'], $functionPath, $method['function_name']);

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

                  }

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

              return self::$triggerTypes;

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

              return $mem->expressionFunctions();

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

                  foreach ($fields as $fieldName => $fieldLabel) {

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

                          $fieldObjects[$fieldName] = new \App\Base(['name' => $fieldName, 'label' => $fieldLabel, 'sort' => false]);

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

                          $taskId = $db->getLastInsertID('com_vtiger_workflowtasks_task_id_seq');

      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 (!file_exists($functionPath)) {

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

                  if (false === file_put_contents($functionPath, $scriptData)) {

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

                      'method_name' => $method['method_name'],

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

              if ($returnVal = \preg_match('/^modules[\\\\|\\/]([A-Z][a-z,A-Z]+)[\\\\|\\/]workflows[\\\\|\\/][A-Z][a-z,A-Z]+\\.php$/', $path, $match)) {

      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 updateActionsSequence(int $wfIdToMove, int $workflowBeforeId, string $moduleName): void

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

              foreach ($tasks as $sequence => $id) {

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

           * @param string $path

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

                      ++$sequence;

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

           * Update tasks sequence.

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

          {

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

              }

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

          {

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

                  $moduleWorkflows = array_keys(self::getWorkflowActionsForModule($moduleName));

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

          public static function updateTasksSequence(array $tasks): void

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

          }

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

           *

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

           * @param array $tasks

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

           * @return void

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

          {

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

           * @return bool Returns true if success

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

      Line exceeds 120 characters; contains 124 characters
      Open

                          $caseSequence .= " WHEN workflow_id = {$db->quoteValue($wfIdToMove)} THEN {$db->quoteValue($sequence)}";

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

           *

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

                  $createCommand->update('com_vtiger_workflowtasks', ['sequence' => $sequence], ['task_id' => $id])->execute();

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

           *

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

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

           * @param int    $wfIdToMove

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

                      $caseSequence .= " WHEN workflow_id = {$db->quoteValue($wfId)} THEN {$db->quoteValue($sequence)}";

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

                  }

      Line exceeds 120 characters; contains 121 characters
      Open

                  $createCommand->update('com_vtiger_workflowtasks', ['sequence' => $sequence], ['task_id' => $id])->execute();

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

          }

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

          public function checkPathForImportMethod(string $path): bool

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

              if ($workflowBeforeId !== $wfIdToMove) {

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

                      if ($wfIdToMove === $wfId) {

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

           *

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

              return (new \App\Db\Query())->select(['workflow_id', 'summary'])

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

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

                  foreach ($moduleWorkflows as $wfId) {

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

                          ++$sequence;

      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

                  ->orderBy(['sequence' => SORT_ASC])

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

           * Check the path for importing the method.

      Line exceeds 120 characters; contains 146 characters
      Open

              if ($returnVal = \preg_match('/^modules[\\\\|\\/]([A-Z][a-z,A-Z]+)[\\\\|\\/]workflows[\\\\|\\/][A-Z][a-z,A-Z]+\\.php$/', $path, $match)) {

      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 ($wfId === $workflowBeforeId) {

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

                  $caseSequence .= ' END';

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

                      'sequence' => new yii\db\Expression($caseSequence),

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

                  ], ['workflow_id' => $moduleWorkflows])->execute();

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

           */

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

                  $caseSequence = 'CASE';

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

                          $caseSequence .= " WHEN workflow_id = {$db->quoteValue($wfIdToMove)} THEN {$db->quoteValue($sequence)}";

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

                      }

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

           */

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

              $createCommand = \App\Db::getInstance()->createCommand();

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

                  ->from('com_vtiger_workflows')

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

           *

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

                  //Check if the module exists

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

                  $returnVal = false !== \vtlib\Module::getInstance($match[1]);

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

           *

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

          /**

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

                  $sequence = 0;

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

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

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

           */

      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

          public static function getWorkflowActionsForModule(string $moduleName): array

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

                  ->createCommand()->queryAllByGroup(1);

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

          }

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

              return $returnVal;

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

           * Update actions sequence.

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

           * @param int    $workflowBeforeId

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

          {

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

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

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

              }

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

          /**

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

           * Get workflow actions for module.

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

          }

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

          /**

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

           *

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

           * @return void

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

              }

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

      class Settings_Workflows_Module_Model extends Settings_Vtiger_Module_Model

      There are no issues that match your filters.

      Category
      Status