yiisoft/yii2

View on GitHub
framework/helpers/BaseArrayHelper.php

Summary

Maintainability
F
3 days
Test Coverage

Function toArray has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public static function toArray($object, $properties = [], $recursive = true)
    {
        if (is_array($object)) {
            if ($recursive) {
                foreach ($object as $key => $value) {
Severity: Minor
Found in framework/helpers/BaseArrayHelper.php - About 5 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function filter has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public static function filter($array, $filters)
    {
        $result = [];
        $excludeFilters = [];

Severity: Minor
Found in framework/helpers/BaseArrayHelper.php - About 4 hrs to fix

Cognitive Complexity

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

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

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

Further reading

The class BaseArrayHelper has 12 public methods. Consider refactoring BaseArrayHelper to keep number of public methods under 10.
Open

class BaseArrayHelper
{
    /**
     * Converts an object or an array of objects into an array.
     * @param object|array|string $object the object to be converted into an array
Severity: Minor
Found in framework/helpers/BaseArrayHelper.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

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

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

class BaseArrayHelper
{
    /**
     * Converts an object or an array of objects into an array.
     * @param object|array|string $object the object to be converted into an array
Severity: Minor
Found in framework/helpers/BaseArrayHelper.php by phpmd

Function index has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static function index($array, $key, $groups = [])
    {
        $result = [];
        $groups = (array) $groups;

Severity: Minor
Found in framework/helpers/BaseArrayHelper.php - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function merge has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public static function merge($a, $b)
    {
        $args = func_get_args();
        $res = array_shift($args);
        while (!empty($args)) {
Severity: Minor
Found in framework/helpers/BaseArrayHelper.php - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

    public static function getValue($array, $key, $default = null)
    {
        if ($key instanceof \Closure) {
            return $key($array, $default);
        }
Severity: Minor
Found in framework/helpers/BaseArrayHelper.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

Function isAssociative has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isAssociative($array, $allStrings = true)
    {
        if (empty($array) || !is_array($array)) {
            return false;
        }
Severity: Minor
Found in framework/helpers/BaseArrayHelper.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

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

    public static function keyExists($key, $array, $caseSensitive = true)
    {
        // ToDo: This check can be removed when the minimum PHP version is >= 8.1 (Yii2.2)
        if (is_float($key)) {
            $key = (int)$key;
Severity: Minor
Found in framework/helpers/BaseArrayHelper.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 htmlEncode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function htmlEncode($data, $valuesOnly = true, $charset = null)
    {
        if ($charset === null) {
            $charset = Yii::$app ? Yii::$app->charset : 'UTF-8';
        }
Severity: Minor
Found in framework/helpers/BaseArrayHelper.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 htmlDecode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public static function htmlDecode($data, $valuesOnly = true)
    {
        $d = [];
        foreach ($data as $key => $value) {
            if (!$valuesOnly && is_string($key)) {
Severity: Minor
Found in framework/helpers/BaseArrayHelper.php - About 45 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 multisort has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function multisort(&$array, $key, $direction = SORT_ASC, $sortFlag = SORT_REGULAR)
    {
        $keys = is_array($key) ? $key : [$key];
        if (empty($keys) || empty($array)) {
            return;
Severity: Minor
Found in framework/helpers/BaseArrayHelper.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

Avoid too many return statements within this method.
Open

        return true;
Severity: Major
Found in framework/helpers/BaseArrayHelper.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return $default;
    Severity: Major
    Found in framework/helpers/BaseArrayHelper.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return $array->$key;
      Severity: Major
      Found in framework/helpers/BaseArrayHelper.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return [$object];
        Severity: Major
        Found in framework/helpers/BaseArrayHelper.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return $default;
          Severity: Major
          Found in framework/helpers/BaseArrayHelper.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return false;
            Severity: Major
            Found in framework/helpers/BaseArrayHelper.php - About 30 mins to fix

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

                  public static function isIndexed($array, $consecutive = false)
                  {
                      if (!is_array($array)) {
                          return false;
                      }
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

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

                  public static function removeValue(&$array, $value)
                  {
                      $result = [];
                      if (is_array($array)) {
                          foreach ($array as $key => $val) {
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

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

                  public static function getColumn($array, $name, $keepKeys = true)
                  {
                      $result = [];
                      if ($keepKeys) {
                          foreach ($array as $k => $element) {
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

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

                  public static function setValue(&$array, $path, $value)
                  {
                      if ($path === null) {
                          $array = $value;
                          return;
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php - About 25 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              The class BaseArrayHelper has 1020 lines of code. Current threshold is 1000. Avoid really long classes.
              Open

              class BaseArrayHelper
              {
                  /**
                   * Converts an object or an array of objects into an array.
                   * @param object|array|string $object the object to be converted into an array
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              The method filter() has an NPath complexity of 492. The configured NPath complexity threshold is 200.
              Open

                  public static function filter($array, $filters)
                  {
                      $result = [];
                      $excludeFilters = [];
              
              
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              NPathComplexity

              Since: 0.1

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

              Example

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

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

              The method getValue() has an NPath complexity of 864. The configured NPath complexity threshold is 200.
              Open

                  public static function getValue($array, $key, $default = null)
                  {
                      if ($key instanceof \Closure) {
                          return $key($array, $default);
                      }
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              NPathComplexity

              Since: 0.1

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

              Example

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

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

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

                  public static function getValue($array, $key, $default = null)
                  {
                      if ($key instanceof \Closure) {
                          return $key($array, $default);
                      }
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              CyclomaticComplexity

              Since: 0.1

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

              Example

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

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

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

                  public static function toArray($object, $properties = [], $recursive = true)
                  {
                      if (is_array($object)) {
                          if ($recursive) {
                              foreach ($object as $key => $value) {
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              CyclomaticComplexity

              Since: 0.1

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

              Example

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

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

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

                  public static function filter($array, $filters)
                  {
                      $result = [];
                      $excludeFilters = [];
              
              
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              CyclomaticComplexity

              Since: 0.1

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

              Example

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

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

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

                  public static function merge($a, $b)
                  {
                      $args = func_get_args();
                      $res = array_shift($args);
                      while (!empty($args)) {
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              CyclomaticComplexity

              Since: 0.1

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

              Example

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

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

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

                  public static function isIn($needle, $haystack, $strict = false)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

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

                  public static function keyExists($key, $array, $caseSensitive = true)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

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

                  public static function htmlEncode($data, $valuesOnly = true, $charset = null)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

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

                  public static function htmlDecode($data, $valuesOnly = true)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

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

                  public static function isIndexed($array, $consecutive = false)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

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

                  public static function isSubset($needles, $haystack, $strict = false)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

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

                  public static function toArray($object, $properties = [], $recursive = true)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

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

                  public static function getColumn($array, $name, $keepKeys = true)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

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

                  public static function isAssociative($array, $allStrings = true)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              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

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

                  public static function getValue($array, $key, $default = null)
                  {
                      if ($key instanceof \Closure) {
                          return $key($array, $default);
                      }
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

              Avoid unused parameters such as '$b'.
              Open

                  public static function merge($a, $b)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              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

              Avoid unused parameters such as '$a'.
              Open

                  public static function merge($a, $b)
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              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

              Avoid using yii\helpers\count() function in while loops.
              Open

                      while (count($keys) > 1) {
                          $key = array_shift($keys);
                          if (!isset($array[$key])) {
                              $array[$key] = [];
                          }
              Severity: Minor
              Found in framework/helpers/BaseArrayHelper.php by phpmd

              CountInLoopExpression

              Since: 2.7.0

              Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

              Example

              class Foo {
              
                public function bar()
                {
                  $array = array();
              
                  for ($i = 0; count($array); $i++) {
                    // ...
                  }
                }
              }

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

              There are no issues that match your filters.

              Category
              Status