src/Phan/Analysis/ConditionVisitorUtil.php

Summary

Maintainability
F
2 wks
Test Coverage

File ConditionVisitorUtil.php has 1275 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Phan\Analysis;
Severity: Major
Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 3 days to fix

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

        protected function combineTypesAfterWeakEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
        {
            // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
            if (!$old_union_type->hasRealTypeSet()) {
                // This is a weak check of equality. We aren't sure of the real types
    Severity: Minor
    Found in src/Phan/Analysis/ConditionVisitorUtil.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

    Function analyzeBinaryConditionSide has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function analyzeBinaryConditionSide(Node $var_node, $expr_node, BinaryCondition $condition): ?Context
        {
            '@phan-var ConditionVisitorUtil|ConditionVisitorInterface $this';
            $kind = $var_node->kind;
            if ($kind === ast\AST_VAR || $kind === ast\AST_DIM) {
    Severity: Minor
    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 3 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function updateVariableToBeNotEqual has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        final public function updateVariableToBeNotEqual(
            Node $var_node,
            $expr,
            Context $context = null
        ): Context {
    Severity: Minor
    Found in src/Phan/Analysis/ConditionVisitorUtil.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

    Method removeTruthyFromVariable has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        final protected function removeTruthyFromVariable(Node $var_node, Context $context, bool $suppress_issues, bool $check_empty): Context
        {
            return $this->updateVariableWithConditionalFilter(
                $var_node,
                $context,
    Severity: Major
    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 2 hrs to fix

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

          final public function updateVariableToBeCompared(
              Node $var_node,
              $expr,
              int $flags
          ): Context {
      Severity: Minor
      Found in src/Phan/Analysis/ConditionVisitorUtil.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 getVariableFromScope has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          final public function getVariableFromScope(Node $var_node, Context $context): ?Variable
          {
              if ($var_node->kind !== ast\AST_VAR) {
                  return null;
              }
      Severity: Minor
      Found in src/Phan/Analysis/ConditionVisitorUtil.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

      Method getVariableFromScope has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          final public function getVariableFromScope(Node $var_node, Context $context): ?Variable
          {
              if ($var_node->kind !== ast\AST_VAR) {
                  return null;
              }
      Severity: Major
      Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 2 hrs to fix

        Method removeLiteralScalarFromVariable has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            final protected function removeLiteralScalarFromVariable(
                Node $var_node,
                Context $context,
                $value,
                bool $strict_equality
        Severity: Major
        Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 2 hrs to fix

          Function getVarNameOfDimNode has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function getVarNameOfDimNode($node): ?string
              {
                  // Loop to support getting the var name in is_array($x['field'][0])
                  while (true) {
                      if (!($node instanceof Node)) {
          Severity: Minor
          Found in src/Phan/Analysis/ConditionVisitorUtil.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 combineTypesAfterStrictEqualityCheck has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function combineTypesAfterStrictEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
              {
                  // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
                  if (!$new_union_type->hasRealTypeSet()) {
                      return $new_union_type->withRealTypeSet($old_union_type->getRealTypeSet());
          Severity: Minor
          Found in src/Phan/Analysis/ConditionVisitorUtil.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 modifyComplexExpression has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function modifyComplexExpression($node, Closure $type_modification_callback, Context $context, array $args): Context
              {
                  for (;;) {
                      if (!$node instanceof Node) {
                          return $context;
          Severity: Minor
          Found in src/Phan/Analysis/ConditionVisitorUtil.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

          Method analyzeClassAssertion has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function analyzeClassAssertion($object_node, $expr_node): ?Context
              {
                  if (!($object_node instanceof Node)) {
                      return null;
                  }
          Severity: Major
          Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 2 hrs to fix

            Method checkRedundantOrImpossibleTruthyCondition has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function checkRedundantOrImpossibleTruthyCondition($node, Context $context, ?UnionType $type, bool $is_negated): void
                {
                    if ($node instanceof Node) {
                        // Here, we only perform the redundant condition checks on whichever ran first, to avoid warning about both impossible and redundant conditions
                        if (isset($node->did_check_redundant_condition)) {
            Severity: Major
            Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 2 hrs to fix

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

                  private function checkErrorProneTruthyCast(Node $node, Context $context, UnionType $union_type): void
                  {
                      // Here, we only perform the redundant condition checks on whichever ran first, to avoid warning about both impossible and redundant conditions
                      if (isset($node->did_check_error_prone_truthy)) {
                          return;
              Severity: Minor
              Found in src/Phan/Analysis/ConditionVisitorUtil.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 modifyComplexExpression has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function modifyComplexExpression($node, Closure $type_modification_callback, Context $context, array $args): Context
                  {
                      for (;;) {
                          if (!$node instanceof Node) {
                              return $context;
              Severity: Minor
              Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                Method updateVariableToBeCompared has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    final public function updateVariableToBeCompared(
                        Node $var_node,
                        $expr,
                        int $flags
                    ): Context {
                Severity: Minor
                Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                  Method checkErrorProneTruthyCast has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function checkErrorProneTruthyCast(Node $node, Context $context, UnionType $union_type): void
                      {
                          // Here, we only perform the redundant condition checks on whichever ran first, to avoid warning about both impossible and redundant conditions
                          if (isset($node->did_check_error_prone_truthy)) {
                              return;
                  Severity: Minor
                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                    Method analyzeBinaryConditionSide has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function analyzeBinaryConditionSide(Node $var_node, $expr_node, BinaryCondition $condition): ?Context
                        {
                            '@phan-var ConditionVisitorUtil|ConditionVisitorInterface $this';
                            $kind = $var_node->kind;
                            if ($kind === ast\AST_VAR || $kind === ast\AST_DIM) {
                    Severity: Minor
                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

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

                          protected function combineTypesAfterWeakEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
                          {
                              // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
                              if (!$old_union_type->hasRealTypeSet()) {
                                  // This is a weak check of equality. We aren't sure of the real types
                      Severity: Minor
                      Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                        Method updateDimExpressionWithConditionalFilter has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            final protected function updateDimExpressionWithConditionalFilter(
                                Node $node,
                                Context $context,
                                Closure $should_filter_cb,
                                Closure $filter_union_type_cb,
                        Severity: Minor
                        Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                          Function updateVariableToBeNotIdentical has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              final public function updateVariableToBeNotIdentical(
                                  Node $var_node,
                                  $expr,
                                  Context $context = null
                              ): Context {
                          Severity: Minor
                          Found in src/Phan/Analysis/ConditionVisitorUtil.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 checkRedundantOrImpossibleTruthyCondition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function checkRedundantOrImpossibleTruthyCondition($node, Context $context, ?UnionType $type, bool $is_negated): void
                              {
                                  if ($node instanceof Node) {
                                      // Here, we only perform the redundant condition checks on whichever ran first, to avoid warning about both impossible and redundant conditions
                                      if (isset($node->did_check_redundant_condition)) {
                          Severity: Minor
                          Found in src/Phan/Analysis/ConditionVisitorUtil.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 updateDimExpressionWithConditionalFilter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              final protected function updateDimExpressionWithConditionalFilter(
                                  Node $node,
                                  Context $context,
                                  Closure $should_filter_cb,
                                  Closure $filter_union_type_cb,
                          Severity: Minor
                          Found in src/Phan/Analysis/ConditionVisitorUtil.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 removeFalseyFromVariable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              final protected function removeFalseyFromVariable(Node $var_node, Context $context, bool $suppress_issues): Context
                              {
                                  return $this->updateVariableWithConditionalFilter(
                                      $var_node,
                                      $context,
                          Severity: Minor
                          Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                            Method asTypeSupportingAccess has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function asTypeSupportingAccess(UnionType $type, int $access_type): UnionType
                                {
                                    $type = $type->asMappedListUnionType(/** @return list<Type> */ static function (Type $type) use ($access_type): array {
                                        if ($access_type === ConditionVisitor::ACCESS_IS_OBJECT) {
                                            if (!$type->isPossiblyObject()) {
                            Severity: Minor
                            Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                              Method updateVariableWithNewType has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  final protected function updateVariableWithNewType(
                                      Node $var_node,
                                      Context $context,
                                      UnionType $new_union_type,
                                      bool $suppress_issues,
                              Severity: Minor
                              Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

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

                                    final public function updateVariableToBeNotEqual(
                                        Node $var_node,
                                        $expr,
                                        Context $context = null
                                    ): Context {
                                Severity: Minor
                                Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                                  Method updateVariableWithConditionalFilter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      final protected function updateVariableWithConditionalFilter(
                                          Node $var_node,
                                          Context $context,
                                          Closure $should_filter_cb,
                                          Closure $filter_union_type_cb,
                                  Severity: Minor
                                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

                                    Method removeTypesNotSupportingAccessFromVariable has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        final protected function removeTypesNotSupportingAccessFromVariable(Node $var_node, Context $context, int $access_type): Context
                                        {
                                            return $this->updateVariableWithConditionalFilter(
                                                $var_node,
                                                $context,
                                    Severity: Minor
                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

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

                                          public function analyzeClassAssertion($object_node, $expr_node): ?Context
                                          {
                                              if (!($object_node instanceof Node)) {
                                                  return null;
                                              }
                                      Severity: Minor
                                      Found in src/Phan/Analysis/ConditionVisitorUtil.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 excludeMatchingTypes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public static function excludeMatchingTypes(CodeBase $code_base, UnionType $affected_type, UnionType $excluded_type): UnionType
                                          {
                                              if ($affected_type->isEmpty() || $excluded_type->isEmpty()) {
                                                  return $affected_type;
                                              }
                                      Severity: Minor
                                      Found in src/Phan/Analysis/ConditionVisitorUtil.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 combineTypesAfterStrictEqualityCheck has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          protected function combineTypesAfterStrictEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
                                          {
                                              // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
                                              if (!$new_union_type->hasRealTypeSet()) {
                                                  return $new_union_type->withRealTypeSet($old_union_type->getRealTypeSet());
                                      Severity: Minor
                                      Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 1 hr to fix

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

                                            final protected function updateVariableWithConditionalFilter(
                                                Node $var_node,
                                                Context $context,
                                                Closure $should_filter_cb,
                                                Closure $filter_union_type_cb,
                                        Severity: Minor
                                        Found in src/Phan/Analysis/ConditionVisitorUtil.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 updateVariableWithNewType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            final protected function updateVariableWithNewType(
                                                Node $var_node,
                                                Context $context,
                                                UnionType $new_union_type,
                                                bool $suppress_issues,
                                        Severity: Minor
                                        Found in src/Phan/Analysis/ConditionVisitorUtil.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

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

                                                Node $var_node,
                                                Context $context,
                                                Closure $should_filter_cb,
                                                Closure $filter_union_type_cb,
                                                bool $suppress_issues,
                                        Severity: Minor
                                        Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 45 mins to fix

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

                                                  Node $node,
                                                  Context $context,
                                                  Closure $should_filter_cb,
                                                  Closure $filter_union_type_cb,
                                                  bool $suppress_issues,
                                          Severity: Minor
                                          Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 45 mins to fix

                                            Method updatePropertyExpressionWithConditionalFilter has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                    Node $node,
                                                    Context $context,
                                                    Closure $should_filter_cb,
                                                    Closure $filter_union_type_cb,
                                                    bool $suppress_issues
                                            Severity: Minor
                                            Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 35 mins to fix

                                              Method updateVariableWithNewType has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                      Node $var_node,
                                                      Context $context,
                                                      UnionType $new_union_type,
                                                      bool $suppress_issues,
                                                      bool $is_weak_type_assertion
                                              Severity: Minor
                                              Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 35 mins to fix

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

                                                    final protected function removeLiteralScalarFromVariable(
                                                        Node $var_node,
                                                        Context $context,
                                                        $value,
                                                        bool $strict_equality
                                                Severity: Minor
                                                Found in src/Phan/Analysis/ConditionVisitorUtil.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 $result;
                                                Severity: Major
                                                Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                      return !$type->containsTruthy();
                                                  Severity: Major
                                                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                            return [];
                                                    Severity: Major
                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return $this->updateVariableWithConditionalFilter(
                                                                  $var_node,
                                                                  $context,
                                                                  static function (UnionType $union_type) use ($cb): bool {
                                                                      return $union_type->hasPhpdocOrRealTypeMatchingCallback($cb);
                                                      Severity: Major
                                                      Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                    return $this->context->withScopeVariable(
                                                                        $variable
                                                                    );
                                                        Severity: Major
                                                        Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                          return [];
                                                          Severity: Major
                                                          Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                                return $this->removeTrueFromVariable($var_node, $context);
                                                            Severity: Major
                                                            Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                                  return \get_class($type) === IntType::class;
                                                              Severity: Major
                                                              Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                    return $context;
                                                                Severity: Major
                                                                Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                          return $context;
                                                                  Severity: Major
                                                                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                            return $context;
                                                                    Severity: Major
                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                          return [$type->withIsNullable(false)];
                                                                      Severity: Major
                                                                      Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                        return [];
                                                                        Severity: Major
                                                                        Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                  return $context;
                                                                          Severity: Major
                                                                          Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                    return $context->getScope()->getVariableByName(
                                                                                        $variable_name
                                                                                    );
                                                                            Severity: Major
                                                                            Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                      return $context;
                                                                              Severity: Major
                                                                              Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                        return $context;
                                                                                Severity: Major
                                                                                Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                          return $type;
                                                                                  Severity: Major
                                                                                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                                    return $context;
                                                                                    Severity: Major
                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                      return $condition->analyzeVar($this, $var, $expr_node);
                                                                                      Severity: Major
                                                                                      Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                return $context;
                                                                                        Severity: Major
                                                                                        Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                  return null;
                                                                                          Severity: Major
                                                                                          Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

                                                                                                    return is_string($var_name) ? $var_name : null;
                                                                                            Severity: Major
                                                                                            Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

                                                                                                                  return !$type->containsFalsey();
                                                                                              Severity: Major
                                                                                              Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

                                                                                                                return $context;
                                                                                                Severity: Major
                                                                                                Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                  Avoid too many return statements within this method.
                                                                                                  Open

                                                                                                          return $context;
                                                                                                  Severity: Major
                                                                                                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                    Avoid too many return statements within this method.
                                                                                                    Open

                                                                                                            return null;
                                                                                                    Severity: Major
                                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                      Avoid too many return statements within this method.
                                                                                                      Open

                                                                                                                  return [$type->asNonFalseyType()];
                                                                                                      Severity: Major
                                                                                                      Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

                                                                                                                        return $condition->analyzeCall($this, $var_node, $expr_node);
                                                                                                        Severity: Major
                                                                                                        Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

                                                                                                                      return $type->withRealTypeSet(UnionType::typeSetFromString(ConditionVisitor::DEFAULTS_FOR_ACCESS_TYPE[$access_type]));
                                                                                                          Severity: Major
                                                                                                          Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                            Avoid too many return statements within this method.
                                                                                                            Open

                                                                                                                    return $context;
                                                                                                            Severity: Major
                                                                                                            Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                              Avoid too many return statements within this method.
                                                                                                              Open

                                                                                                                                              return NonZeroIntType::instance($type->isNullable());
                                                                                                              Severity: Major
                                                                                                              Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                Avoid too many return statements within this method.
                                                                                                                Open

                                                                                                                                return null;
                                                                                                                Severity: Major
                                                                                                                Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                  Avoid too many return statements within this method.
                                                                                                                  Open

                                                                                                                              return (new AssignmentVisitor(
                                                                                                                                  $this->code_base,
                                                                                                                                  // We clone the original context to avoid affecting the original context for the elseif.
                                                                                                                                  // AssignmentVisitor modifies the provided context in place.
                                                                                                                                  //
                                                                                                                  Severity: Major
                                                                                                                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                    Avoid too many return statements within this method.
                                                                                                                    Open

                                                                                                                                    return $this->removeLiteralScalarFromVariable($var_node, $context, $expr, true);
                                                                                                                    Severity: Major
                                                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                      Avoid too many return statements within this method.
                                                                                                                      Open

                                                                                                                                                  return $type;
                                                                                                                      Severity: Major
                                                                                                                      Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                        Avoid too many return statements within this method.
                                                                                                                        Open

                                                                                                                                            return $this->removeNullFromVariable($var_node, $context, false);
                                                                                                                        Severity: Major
                                                                                                                        Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                          Avoid too many return statements within this method.
                                                                                                                          Open

                                                                                                                                              return $this->removeFalseFromVariable($var_node, $context);
                                                                                                                          Severity: Major
                                                                                                                          Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                            Avoid too many return statements within this method.
                                                                                                                            Open

                                                                                                                                                return $context->withScopeVariable(
                                                                                                                                                    $variable
                                                                                                                                                );
                                                                                                                            Severity: Major
                                                                                                                            Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                              Avoid too many return statements within this method.
                                                                                                                              Open

                                                                                                                                          return;
                                                                                                                              Severity: Major
                                                                                                                              Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                Open

                                                                                                                                            return $condition->analyzeComplexCondition($this, $tmp, $expr_node);
                                                                                                                                Severity: Major
                                                                                                                                Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                  Open

                                                                                                                                          return null;
                                                                                                                                  Severity: Major
                                                                                                                                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 30 mins to fix

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

                                                                                                                                        protected function analyzeBinaryConditionPattern($left, $right, BinaryCondition $condition): Context
                                                                                                                                        {
                                                                                                                                            if ($left instanceof Node) {
                                                                                                                                                $result = $this->analyzeBinaryConditionSide($left, $right, $condition);
                                                                                                                                                if ($result !== null) {
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.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 getTypesFallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                    Open

                                                                                                                                        final protected function getTypesFallback(Node $var_node, Context $context): ?UnionType
                                                                                                                                        {
                                                                                                                                            if ($var_node->kind !== ast\AST_VAR) {
                                                                                                                                                return null;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.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 method combineTypesAfterWeakEqualityCheck() has an NPath complexity of 568. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        protected function combineTypesAfterWeakEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
                                                                                                                                        {
                                                                                                                                            // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
                                                                                                                                            if (!$old_union_type->hasRealTypeSet()) {
                                                                                                                                                // This is a weak check of equality. We aren't sure of the real types

                                                                                                                                    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 analyzeBinaryConditionSide() has an NPath complexity of 1200. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        private function analyzeBinaryConditionSide(Node $var_node, $expr_node, BinaryCondition $condition): ?Context
                                                                                                                                        {
                                                                                                                                            '@phan-var ConditionVisitorUtil|ConditionVisitorInterface $this';
                                                                                                                                            $kind = $var_node->kind;
                                                                                                                                            if ($kind === ast\AST_VAR || $kind === ast\AST_DIM) {

                                                                                                                                    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 asTypeSupportingAccess() has an NPath complexity of 288. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public static function asTypeSupportingAccess(UnionType $type, int $access_type): UnionType
                                                                                                                                        {
                                                                                                                                            $type = $type->asMappedListUnionType(/** @return list<Type> */ static function (Type $type) use ($access_type): array {
                                                                                                                                                if ($access_type === ConditionVisitor::ACCESS_IS_OBJECT) {
                                                                                                                                                    if (!$type->isPossiblyObject()) {

                                                                                                                                    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 analyzeClassAssertion() has an NPath complexity of 288. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function analyzeClassAssertion($object_node, $expr_node): ?Context
                                                                                                                                        {
                                                                                                                                            if (!($object_node instanceof Node)) {
                                                                                                                                                return null;
                                                                                                                                            }

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

                                                                                                                                        public function analyzeClassAssertion($object_node, $expr_node): ?Context
                                                                                                                                        {
                                                                                                                                            if (!($object_node instanceof Node)) {
                                                                                                                                                return null;
                                                                                                                                            }

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

                                                                                                                                        final protected function updateDimExpressionWithConditionalFilter(
                                                                                                                                            Node $node,
                                                                                                                                            Context $context,
                                                                                                                                            Closure $should_filter_cb,
                                                                                                                                            Closure $filter_union_type_cb,

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

                                                                                                                                        public function checkRedundantOrImpossibleTruthyCondition($node, Context $context, ?UnionType $type, bool $is_negated): void
                                                                                                                                        {
                                                                                                                                            if ($node instanceof Node) {
                                                                                                                                                // Here, we only perform the redundant condition checks on whichever ran first, to avoid warning about both impossible and redundant conditions
                                                                                                                                                if (isset($node->did_check_redundant_condition)) {

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

                                                                                                                                        protected function combineTypesAfterStrictEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
                                                                                                                                        {
                                                                                                                                            // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
                                                                                                                                            if (!$new_union_type->hasRealTypeSet()) {
                                                                                                                                                return $new_union_type->withRealTypeSet($old_union_type->getRealTypeSet());

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

                                                                                                                                        final public function updateVariableToBeNotEqual(
                                                                                                                                            Node $var_node,
                                                                                                                                            $expr,
                                                                                                                                            Context $context = null
                                                                                                                                        ): Context {

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

                                                                                                                                        private function checkErrorProneTruthyCast(Node $node, Context $context, UnionType $union_type): void
                                                                                                                                        {
                                                                                                                                            // Here, we only perform the redundant condition checks on whichever ran first, to avoid warning about both impossible and redundant conditions
                                                                                                                                            if (isset($node->did_check_error_prone_truthy)) {
                                                                                                                                                return;

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

                                                                                                                                        final protected function removeLiteralScalarFromVariable(
                                                                                                                                            Node $var_node,
                                                                                                                                            Context $context,
                                                                                                                                            $value,
                                                                                                                                            bool $strict_equality

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

                                                                                                                                        final protected function removeFalseyFromVariable(Node $var_node, Context $context, bool $suppress_issues): Context
                                                                                                                                        {
                                                                                                                                            return $this->updateVariableWithConditionalFilter(
                                                                                                                                                $var_node,
                                                                                                                                                $context,

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

                                                                                                                                        protected function combineTypesAfterWeakEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
                                                                                                                                        {
                                                                                                                                            // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
                                                                                                                                            if (!$old_union_type->hasRealTypeSet()) {
                                                                                                                                                // This is a weak check of equality. We aren't sure of the real types

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

                                                                                                                                        final protected function removeTruthyFromVariable(Node $var_node, Context $context, bool $suppress_issues, bool $check_empty): Context
                                                                                                                                        {
                                                                                                                                            return $this->updateVariableWithConditionalFilter(
                                                                                                                                                $var_node,
                                                                                                                                                $context,

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

                                                                                                                                        final public function updateVariableToBeCompared(
                                                                                                                                            Node $var_node,
                                                                                                                                            $expr,
                                                                                                                                            int $flags
                                                                                                                                        ): Context {

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

                                                                                                                                        protected function modifyComplexExpression($node, Closure $type_modification_callback, Context $context, array $args): Context
                                                                                                                                        {
                                                                                                                                            for (;;) {
                                                                                                                                                if (!$node instanceof Node) {
                                                                                                                                                    return $context;

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

                                                                                                                                        final public function getVariableFromScope(Node $var_node, Context $context): ?Variable
                                                                                                                                        {
                                                                                                                                            if ($var_node->kind !== ast\AST_VAR) {
                                                                                                                                                return null;
                                                                                                                                            }

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

                                                                                                                                        private static function getVarNameOfDimNode($node): ?string
                                                                                                                                        {
                                                                                                                                            // Loop to support getting the var name in is_array($x['field'][0])
                                                                                                                                            while (true) {
                                                                                                                                                if (!($node instanceof Node)) {

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

                                                                                                                                        public static function asTypeSupportingAccess(UnionType $type, int $access_type): UnionType
                                                                                                                                        {
                                                                                                                                            $type = $type->asMappedListUnionType(/** @return list<Type> */ static function (Type $type) use ($access_type): array {
                                                                                                                                                if ($access_type === ConditionVisitor::ACCESS_IS_OBJECT) {
                                                                                                                                                    if (!$type->isPossiblyObject()) {

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

                                                                                                                                        private function analyzeBinaryConditionSide(Node $var_node, $expr_node, BinaryCondition $condition): ?Context
                                                                                                                                        {
                                                                                                                                            '@phan-var ConditionVisitorUtil|ConditionVisitorInterface $this';
                                                                                                                                            $kind = $var_node->kind;
                                                                                                                                            if ($kind === ast\AST_VAR || $kind === ast\AST_DIM) {

                                                                                                                                    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

                                                                                                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                    Open

                                                                                                                                        final protected function removeFalseFromVariable(Node $var_node, Context $context): Context
                                                                                                                                        {
                                                                                                                                            return $this->updateVariableWithConditionalFilter(
                                                                                                                                                $var_node,
                                                                                                                                                $context,
                                                                                                                                    Severity: Major
                                                                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php and 1 other location - About 3 hrs to fix
                                                                                                                                    src/Phan/Analysis/ConditionVisitorUtil.php on lines 577..599

                                                                                                                                    Duplicated Code

                                                                                                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                    Tuning

                                                                                                                                    This issue has a mass of 143.

                                                                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                    Refactorings

                                                                                                                                    Further Reading

                                                                                                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                    Open

                                                                                                                                        final protected function removeTrueFromVariable(Node $var_node, Context $context): Context
                                                                                                                                        {
                                                                                                                                            return $this->updateVariableWithConditionalFilter(
                                                                                                                                                $var_node,
                                                                                                                                                $context,
                                                                                                                                    Severity: Major
                                                                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php and 1 other location - About 3 hrs to fix
                                                                                                                                    src/Phan/Analysis/ConditionVisitorUtil.php on lines 553..575

                                                                                                                                    Duplicated Code

                                                                                                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                    Tuning

                                                                                                                                    This issue has a mass of 143.

                                                                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                    Refactorings

                                                                                                                                    Further Reading

                                                                                                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                    Open

                                                                                                                                        final public function updateVariableToBeEqual(
                                                                                                                                            Node $var_node,
                                                                                                                                            $expr,
                                                                                                                                            Context $context = null
                                                                                                                                        ): Context {
                                                                                                                                    Severity: Major
                                                                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php and 1 other location - About 1 hr to fix
                                                                                                                                    src/Phan/Analysis/ConditionVisitorUtil.php on lines 900..915

                                                                                                                                    Duplicated Code

                                                                                                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                    Tuning

                                                                                                                                    This issue has a mass of 115.

                                                                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                    Refactorings

                                                                                                                                    Further Reading

                                                                                                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                    Open

                                                                                                                                        final public function updateVariableToBeIdentical(
                                                                                                                                            Node $var_node,
                                                                                                                                            $expr,
                                                                                                                                            Context $context = null
                                                                                                                                        ): Context {
                                                                                                                                    Severity: Major
                                                                                                                                    Found in src/Phan/Analysis/ConditionVisitorUtil.php and 1 other location - About 1 hr to fix
                                                                                                                                    src/Phan/Analysis/ConditionVisitorUtil.php on lines 922..937

                                                                                                                                    Duplicated Code

                                                                                                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                    Tuning

                                                                                                                                    This issue has a mass of 115.

                                                                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                    Refactorings

                                                                                                                                    Further Reading

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

                                                                                                                                                    $cb = static function (Type $type) use ($value): bool {

                                                                                                                                    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

                                                                                                                                    There are no issues that match your filters.

                                                                                                                                    Category
                                                                                                                                    Status