src/Phan/Analysis/ParameterTypesAnalyzer.php

Summary

Maintainability
F
2 wks
Test Coverage

File ParameterTypesAnalyzer.php has 1071 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

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

    Function analyzeRealSignatureCompatibility has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function analyzeRealSignatureCompatibility(CodeBase $code_base, FunctionInterface $method, int $minimum_target_php_version): void
        {
            $php70_checks = $minimum_target_php_version < 70100;
    
            foreach ($method->getRealParameterList() as $real_parameter) {
    Severity: Minor
    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 day to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function analyzeParameterTypesInner has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function analyzeParameterTypesInner(
            CodeBase $code_base,
            FunctionInterface $method
        ): void {
            if (Config::getValue('check_docblock_signature_param_type_match')) {
    Severity: Minor
    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 day to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function analyzeOverrideSignatureForOverriddenMethod has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function analyzeOverrideSignatureForOverriddenMethod(
            CodeBase $code_base,
            Method $method,
            Clazz $class,
            Method $o_method
    Severity: Minor
    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 day to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method analyzeOverrideSignatureForOverriddenMethod has 191 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function analyzeOverrideSignatureForOverriddenMethod(
            CodeBase $code_base,
            Method $method,
            Clazz $class,
            Method $o_method
    Severity: Major
    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 7 hrs to fix

      Function analyzeOverrideRealSignature has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function analyzeOverrideRealSignature(
              CodeBase $code_base,
              Method $method,
              Clazz $class,
              Method $o_method,
      Severity: Minor
      Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 7 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 analyzeOverrideRealSignature has 163 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function analyzeOverrideRealSignature(
              CodeBase $code_base,
              Method $method,
              Clazz $class,
              Method $o_method,
      Severity: Major
      Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 6 hrs to fix

        Method analyzeParameterTypesInner has 143 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function analyzeParameterTypesInner(
                CodeBase $code_base,
                FunctionInterface $method
            ): void {
                if (Config::getValue('check_docblock_signature_param_type_match')) {
        Severity: Major
        Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 5 hrs to fix

          Method analyzeRealSignatureCompatibility has 134 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function analyzeRealSignatureCompatibility(CodeBase $code_base, FunctionInterface $method, int $minimum_target_php_version): void
              {
                  $php70_checks = $minimum_target_php_version < 70100;
          
                  foreach ($method->getRealParameterList() as $real_parameter) {
          Severity: Major
          Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 5 hrs to fix

            Function inheritPHPDoc has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function inheritPHPDoc(
                    CodeBase $code_base,
                    Method $method,
                    Method $o_method
                ): void {
            Severity: Minor
            Found in src/Phan/Analysis/ParameterTypesAnalyzer.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

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

            class ParameterTypesAnalyzer
            {
            
                /**
                 * Check function, closure, and method parameters to make sure they're valid

            Method tryToAssignPHPDocTypeToParameter has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function tryToAssignPHPDocTypeToParameter(
                    CodeBase $code_base,
                    FunctionInterface $method,
                    int $i,
                    Parameter $parameter,
            Severity: Minor
            Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

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

                  private static function tryToAssignPHPDocTypeToParameter(
                      CodeBase $code_base,
                      FunctionInterface $method,
                      int $i,
                      Parameter $parameter,
              Severity: Minor
              Found in src/Phan/Analysis/ParameterTypesAnalyzer.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 warnOverridingFinalMethod has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function warnOverridingFinalMethod(CodeBase $code_base, Method $method, Clazz $class, Method $o_method): void
                  {
                      if ($method->isFromPHPDoc()) {
                          // TODO: Track phpdoc methods separately from real methods
                          if ($class->checkHasSuppressIssueAndIncrementCount(Issue::AccessOverridesFinalMethodPHPDoc)) {
              Severity: Minor
              Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

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

                    private static function inheritPHPDoc(
                        CodeBase $code_base,
                        Method $method,
                        Method $o_method
                    ): void {
                Severity: Minor
                Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

                  Method emitSignatureRealMismatchIssue has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static function emitSignatureRealMismatchIssue(
                          CodeBase $code_base,
                          Method $method,
                          Method $o_method,
                          string $issue_type,
                  Severity: Minor
                  Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

                    Method checkCommentParametersAreInOrder has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static function checkCommentParametersAreInOrder(CodeBase $code_base, FunctionInterface $method): void
                        {
                            $comment = $method->getComment();
                            if ($comment === null) {
                                return;
                    Severity: Minor
                    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                                  if (!($o_return_union_type->isEqualTo($return_union_type) || (
                                      ($o_return_union_type->containsNullable() && !$o_return_union_type->isNull()) && ($o_return_union_type->nonNullableClone()->isEqualTo($return_union_type)))
                                      )) {
                                      // There is one exception to this in php 7.1 - the pseudo-type "iterable" can replace ArrayAccess/array in a subclass
                                      // TODO: Traversable and array work, but Iterator doesn't. Check for those specific cases?
                      Severity: Critical
                      Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

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

                            private static function analyzeOverrideSignature(
                                CodeBase $code_base,
                                Method $method
                            ): void {
                                if (!Config::getValue('analyze_signature_compatibility')) {
                        Severity: Minor
                        Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          Open

                                          if (!$o_parameter_union_type->isEqualTo($parameter_union_type) &&
                                              !($parameter_union_type->containsNullable() && $o_parameter_union_type->isEqualTo($parameter_union_type->nonNullableClone()))
                                          ) {
                                              // There is one exception to this in php 7.1 - the pseudo-type "iterable" can replace ArrayAccess/array in a subclass
                                              // TODO: Traversable and array work, but Iterator doesn't. Check for those specific cases?
                          Severity: Major
                          Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

                            Method emitSignatureRealMismatchIssue has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    CodeBase $code_base,
                                    Method $method,
                                    Method $o_method,
                                    string $issue_type,
                                    string $internal_issue_type,
                            Severity: Major
                            Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

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

                                  private static function warnOverridingFinalMethod(CodeBase $code_base, Method $method, Clazz $class, Method $o_method): void
                                  {
                                      if ($method->isFromPHPDoc()) {
                                          // TODO: Track phpdoc methods separately from real methods
                                          if ($class->checkHasSuppressIssueAndIncrementCount(Issue::AccessOverridesFinalMethodPHPDoc)) {
                              Severity: Minor
                              Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 55 mins to fix

                              Cognitive Complexity

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

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

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

                              Further reading

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

                                      CodeBase $code_base,
                                      FunctionInterface $method,
                                      int $i,
                                      Parameter $parameter,
                                      UnionType $real_param_type,
                              Severity: Minor
                              Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 45 mins to fix

                                Function analyzeOverrideSignature has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    private static function analyzeOverrideSignature(
                                        CodeBase $code_base,
                                        Method $method
                                    ): void {
                                        if (!Config::getValue('analyze_signature_compatibility')) {
                                Severity: Minor
                                Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 45 mins to fix

                                Cognitive Complexity

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

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

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

                                Further reading

                                Function checkCommentParametersAreInOrder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    private static function checkCommentParametersAreInOrder(CodeBase $code_base, FunctionInterface $method): void
                                    {
                                        $comment = $method->getComment();
                                        if ($comment === null) {
                                            return;
                                Severity: Minor
                                Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 45 mins to fix

                                Cognitive Complexity

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

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

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

                                Further reading

                                Function analyzeParameterTypesDocblockSignaturesMatch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    private static function analyzeParameterTypesDocblockSignaturesMatch(
                                        CodeBase $code_base,
                                        FunctionInterface $method
                                    ): void {
                                        $phpdoc_parameter_map = $method->getPHPDocParameterTypeMap();
                                Severity: Minor
                                Found in src/Phan/Analysis/ParameterTypesAnalyzer.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

                                Consider simplifying this complex logical expression.
                                Open

                                                if ($o_real_parameter !== null && $real_parameter !== null && !$real_parameter->getUnionType()->isEmptyOrMixed() && $o_real_parameter->getUnionType()->isEmptyOrMixed()
                                                    && (!$method->isFromPHPDoc() || $parameter->getUnionType()->isEmptyOrMixed())) {
                                                    $signatures_match = false;
                                                    $mismatch_details = "Cannot use $parameter with a real type to override parameter $o_parameter without a real type";
                                                    break;
                                Severity: Major
                                Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 40 mins to fix

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

                                          CodeBase $code_base,
                                          Method $method,
                                          Clazz $class,
                                          Method $o_method,
                                          Clazz $o_class
                                  Severity: Minor
                                  Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 35 mins to fix

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

                                        private static function recordOutputReferences(FunctionInterface $method): void
                                        {
                                            foreach ($method->getOutputReferenceParamNames() as $output_param_name) {
                                                foreach ($method->getRealParameterList() as $parameter) {
                                                    // TODO: Emit an issue if the (at)phan-output-reference is on a non-reference (at)param?
                                    Severity: Minor
                                    Found in src/Phan/Analysis/ParameterTypesAnalyzer.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 $mapped_parameter;
                                    Severity: Major
                                    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

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

                                        The method analyzeOverrideSignatureForOverriddenMethod() has 278 lines of code. Current threshold is set to 100. Avoid really long methods.
                                        Open

                                            private static function analyzeOverrideSignatureForOverriddenMethod(
                                                CodeBase $code_base,
                                                Method $method,
                                                Clazz $class,
                                                Method $o_method

                                        The method analyzeParameterTypesInner() has an NPath complexity of 508416. The configured NPath complexity threshold is 200.
                                        Open

                                            private static function analyzeParameterTypesInner(
                                                CodeBase $code_base,
                                                FunctionInterface $method
                                            ): void {
                                                if (Config::getValue('check_docblock_signature_param_type_match')) {

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

                                            private static function analyzeOverrideRealSignature(
                                                CodeBase $code_base,
                                                Method $method,
                                                Clazz $class,
                                                Method $o_method,

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

                                            private static function analyzeRealSignatureCompatibility(CodeBase $code_base, FunctionInterface $method, int $minimum_target_php_version): void
                                            {
                                                $php70_checks = $minimum_target_php_version < 70100;
                                        
                                                foreach ($method->getRealParameterList() as $real_parameter) {

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

                                            private static function analyzeRealSignatureCompatibility(CodeBase $code_base, FunctionInterface $method, int $minimum_target_php_version): void
                                            {
                                                $php70_checks = $minimum_target_php_version < 70100;
                                        
                                                foreach ($method->getRealParameterList() as $real_parameter) {

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

                                        class ParameterTypesAnalyzer
                                        {
                                        
                                            /**
                                             * Check function, closure, and method parameters to make sure they're valid

                                        The method analyzeOverrideSignatureForOverriddenMethod() has an NPath complexity of 263023200. The configured NPath complexity threshold is 200.
                                        Open

                                            private static function analyzeOverrideSignatureForOverriddenMethod(
                                                CodeBase $code_base,
                                                Method $method,
                                                Clazz $class,
                                                Method $o_method

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

                                            private static function analyzeOverrideRealSignature(
                                                CodeBase $code_base,
                                                Method $method,
                                                Clazz $class,
                                                Method $o_method,

                                        The method analyzeParameterTypesInner() has 164 lines of code. Current threshold is set to 100. Avoid really long methods.
                                        Open

                                            private static function analyzeParameterTypesInner(
                                                CodeBase $code_base,
                                                FunctionInterface $method
                                            ): void {
                                                if (Config::getValue('check_docblock_signature_param_type_match')) {

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

                                            private static function analyzeOverrideSignatureForOverriddenMethod(
                                                CodeBase $code_base,
                                                Method $method,
                                                Clazz $class,
                                                Method $o_method

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

                                            private static function analyzeParameterTypesInner(
                                                CodeBase $code_base,
                                                FunctionInterface $method
                                            ): void {
                                                if (Config::getValue('check_docblock_signature_param_type_match')) {

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

                                            private static function tryToAssignPHPDocTypeToParameter(
                                                CodeBase $code_base,
                                                FunctionInterface $method,
                                                int $i,
                                                Parameter $parameter,

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

                                            private static function analyzeRealSignatureCompatibility(CodeBase $code_base, FunctionInterface $method, int $minimum_target_php_version): void
                                            {
                                                $php70_checks = $minimum_target_php_version < 70100;
                                        
                                                foreach ($method->getRealParameterList() as $real_parameter) {

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

                                            private static function analyzeOverrideRealSignature(
                                                CodeBase $code_base,
                                                Method $method,
                                                Clazz $class,
                                                Method $o_method,

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

                                            private static function inheritPHPDoc(
                                                CodeBase $code_base,
                                                Method $method,
                                                Method $o_method
                                            ): void {

                                        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 class ParameterTypesAnalyzer has a coupling between objects value of 23. Consider to reduce the number of dependencies under 13.
                                        Open

                                        class ParameterTypesAnalyzer
                                        {
                                        
                                            /**
                                             * Check function, closure, and method parameters to make sure they're valid

                                        CouplingBetweenObjects

                                        Since: 1.1.0

                                        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                                        Example

                                        class Foo {
                                            /**
                                             * @var \foo\bar\X
                                             */
                                            private $x = null;
                                        
                                            /**
                                             * @var \foo\bar\Y
                                             */
                                            private $y = null;
                                        
                                            /**
                                             * @var \foo\bar\Z
                                             */
                                            private $z = null;
                                        
                                            public function setFoo(\Foo $foo) {}
                                            public function setBar(\Bar $bar) {}
                                            public function setBaz(\Baz $baz) {}
                                        
                                            /**
                                             * @return \SplObjectStorage
                                             * @throws \OutOfRangeException
                                             * @throws \InvalidArgumentException
                                             * @throws \ErrorException
                                             */
                                            public function process(\Iterator $it) {}
                                        
                                            // ...
                                        }

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

                                        Avoid using empty try-catch blocks in warnOverridingFinalMethod.
                                        Open

                                                    } catch (CodeBaseException $_) {
                                                    }

                                        EmptyCatchBlock

                                        Since: 2.7.0

                                        Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

                                        Example

                                        class Foo {
                                        
                                          public function bar()
                                          {
                                              try {
                                                  // ...
                                              } catch (Exception $e) {} // empty catch block
                                          }
                                        }

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

                                        Avoid using empty try-catch blocks in analyzeParameterTypes.
                                        Open

                                                } catch (RecursionDepthException $_) {
                                                }

                                        EmptyCatchBlock

                                        Since: 2.7.0

                                        Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

                                        Example

                                        class Foo {
                                        
                                          public function bar()
                                          {
                                              try {
                                                  // ...
                                              } catch (Exception $e) {} // empty catch block
                                          }
                                        }

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

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

                                                        if ($type_class === ObjectType::class) {
                                                            if ($minimum_target_php_version < 70200) {
                                                                Issue::maybeEmit(
                                                                    $code_base,
                                                                    $method->getContext(),
                                        Severity: Major
                                        Found in src/Phan/Analysis/ParameterTypesAnalyzer.php and 1 other location - About 1 hr to fix
                                        src/Phan/Analysis/ParameterTypesAnalyzer.php on lines 352..372

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

                                        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

                                                    if ($type_class === ObjectType::class) {
                                                        if ($minimum_target_php_version < 70200) {
                                                            Issue::maybeEmit(
                                                                $code_base,
                                                                $method->getContext(),
                                        Severity: Major
                                        Found in src/Phan/Analysis/ParameterTypesAnalyzer.php and 1 other location - About 1 hr to fix
                                        src/Phan/Analysis/ParameterTypesAnalyzer.php on lines 274..294

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

                                        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

                                                    if ($parameter->isVariadic() != $o_parameter->isVariadic()) {
                                                        $is_variadic = $parameter->isVariadic();
                                                        self::emitSignatureRealMismatchIssue(
                                                            $code_base,
                                                            $method,
                                        Severity: Major
                                        Found in src/Phan/Analysis/ParameterTypesAnalyzer.php and 1 other location - About 1 hr to fix
                                        src/Phan/Analysis/ParameterTypesAnalyzer.php on lines 864..877

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

                                        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

                                                    if ($parameter->isPassByReference() != $o_parameter->isPassByReference()) {
                                                        $is_reference = $parameter->isPassByReference();
                                                        self::emitSignatureRealMismatchIssue(
                                                            $code_base,
                                                            $method,
                                        Severity: Major
                                        Found in src/Phan/Analysis/ParameterTypesAnalyzer.php and 1 other location - About 1 hr to fix
                                        src/Phan/Analysis/ParameterTypesAnalyzer.php on lines 881..894

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

                                        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 $i. Configured minimum length is 3.
                                        Open

                                                int $i,

                                        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